Trailing slash problem?

Discuss practical ways rearrange URLs using mod_rewrite.

Trailing slash problem?

Postby ohyoko2 » Thu Feb 17, 2005 8:26 pm

How do I fix the problem of the trailing slash on URLs that reference directories (e.g., have /etc/foo and /etc/foo/ rewrite the same thing).

Here's what I have:

Code: Select all
RewriteRule ^etc/([0-9A-Za-z_]+)/$ /index.php?id=$1 [L]


I think I should have to place a [^/] somewhere; but, I don't know where. What do I change, within the rule, to match it without a trailing slash?
ohyoko2
 

Postby Caterham » Fri Feb 18, 2005 4:48 am

make the slash optinal (? = 0 or 1 char, in this case 0 or 1 slash)

Code: Select all
RewriteRule ^etc/([0-9A-Za-z_]+)/?$ /index.php?id=$1 [L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 26 guests

cron