Handling Trailing Slashes In RewriteRule
Posted: Wed Sep 09, 2009 1:37 pm
I like trailing slashes. I think they are nice. But why do they hate me?
This works perfect as long as I include a trailing slash like mysite.com/profile/username/
If I do not include the trailing slash I get a 404 error.
I would like to just 301 redirect anyone who forgets the slash to the url containing the slash.
Throwing this above the other rule put me in an infinite loop.
Any other ideas?
This works perfect as long as I include a trailing slash like mysite.com/profile/username/
Code: Select all
RewriteRule ^profile/(.*)/$ /profile/index.php?username=$1 [NC,L]I would like to just 301 redirect anyone who forgets the slash to the url containing the slash.
Code: Select all
RewriteRule ^profile/(.*)$ /profile/$1/ [R=301,L]Any other ideas?