Simple Q's

New to mod_rewrite? This is a good place to start.

Postby Guest » Sat Jun 22, 2002 6:19 am

Hi there.....
I wanted to redirect urls such as http://www.domain.com/folder
or
http://www.domain.com/folder/

to a file:
display.php?category=folder

I have managed to do this with mod_rewrite, however I dont know how to deal with the case if there is no trailing slash..

Here is what I used

RewriteRule ^([a-z]*)$ subcontent.php?category=$1

I just need a way to direct them to the same place whether they use a trailing slash or not.....

thanks...also what does this [L] mean..
Guest
 

Postby Brett » Mon Aug 05, 2002 1:18 pm

Try this:
Code: Select all
RewriteEngine on
RewriteRule ^([a-z]*)/?$ index.php?category=$1

[L] after a RewriteRule means "last rule", i.e. if this rule is applied, then don't apply any of the rules that follow.
Brett
 
Posts: 82
Joined: Tue Jul 10, 2001 4:00 pm
Location: yohost.com

Postby realbeginner » Tue Aug 05, 2003 12:26 am

To a real beginner this simple case can be confusing, first the "guest" wants to go to this file:

display.php?category=folder

for which he uses this rewrite rule:

RewriteRule ^([a-z]*)$ subcontent.php?category=$1

and then Brett suggests this other rule:

RewriteRule ^([a-z]*)/?$ index.php?category=$1
realbeginner
 


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 78 guests

cron