Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
.htaccess Folder Redirections
Old 04-24-2009, 04:01 PM .htaccess Folder Redirections
portkey's Avatar
Skilled Talker

Posts: 54
Name: Erica Dion
Trades: 0
Hey everyone! Hopefully this is the right place to post this. I'm trying to work on a redirection for a blog-like script, and I figured .htaccess would be the best way. Every user will have their own link such as mywebsite.com/acooluser and rather than make a folder for each user, I'm going to use the rewrite function.

Now I came into a problem on folders that do exist and can be navigated to, so I wanted code that would skip the folders that exist, but if they didn't exist, it would redirect to the profile page and show that person's information.

Here's what I'm using right now:
Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME}	!-d	
RewriteRule ^.*[/]$ 			/purefm_v2/djs.php?did=$1	[NC,L]
The problem is, the RewriteRule never gets called. It's as if all directories exist because it tries to go to a non-existing one and issues a 404 error. Does anyone know what I missed?
portkey is offline
Reply With Quote
View Public Profile Visit portkey's homepage!
 
 
Register now for full access!
Old 04-25-2009, 12:56 AM Re: .htaccess Folder Redirections
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
Quote:
The problem is, the RewriteRule never gets called. It's as if all directories exist because it tries to go to a non-existing one and issues a 404 error. Does anyone know what I missed?
what is the directory it tries to go that is causes 404 error?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 04-25-2009, 10:22 AM Re: .htaccess Folder Redirections
kids's Avatar
Ultra Talker

Posts: 301
Trades: 0
Hi,

I wanna do like this

article ID = x
article title = "how to do"

and user read this article by user URL:

.../read_article.php?id=x

pls give me rule to change it to (how to get title?)
.../articles/how-to-do.html

Thanks
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by kids; 04-25-2009 at 10:23 AM..
kids is offline
Reply With Quote
View Public Profile Visit kids's homepage!
 
Old 04-25-2009, 08:35 PM Re: .htaccess Folder Redirections
portkey's Avatar
Skilled Talker

Posts: 54
Name: Erica Dion
Trades: 0
thanks for the help! it dawned on me while answering "kids" question that my query was demanding for an end forward slash which I didn't want to have in my URL, so I changed it to this but now I get a Internal Server Error:

Code:
RewriteCond %{REQUEST_FILENAME}	!-d	
RewriteRule ^.*[/]?$ 		/purefm_v2/djs.php?did=$1	[NC,L]
is there a way to write this so that I don't require a forward slash in the end?

Last edited by portkey; 04-25-2009 at 08:49 PM.. Reason: new problem
portkey is offline
Reply With Quote
View Public Profile Visit portkey's homepage!
 
Old 04-25-2009, 08:41 PM Re: .htaccess Folder Redirections
portkey's Avatar
Skilled Talker

Posts: 54
Name: Erica Dion
Trades: 0
oh, and to answer your questions kids:

Code:
RewriteRule ^articles[/]([a-zA-Z0-9]+).html$ read_article.php?title=$1 [L]
that's your only option with .htaccess. It can't execute queries so you'd have to have your read_article.php select the id based on the title
portkey is offline
Reply With Quote
View Public Profile Visit portkey's homepage!
 
Reply     « Reply to .htaccess Folder Redirections
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23695 seconds with 12 queries