Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- .htaccess RewriteRule, ignore trailing slash
- Jason Carlton
June 25, 2010, 1:33 am
rate this thread
I'm hoping you guys can help me figure this one out. I'm rewriting
It works OK, but if they go to www.mydomain.com/var/ (with the
trailing slash), then they get a 404.
Here's the .htaccess code I'm using. Any suggestions on how to modify
it to allow the trailing slash?
# Make sure that it contains valid characters
RewriteCond % ^/([a-zA-Z0-9_.-]+)$
# Ensure the MODIFIED request is not for a real file
RewriteCond % !-f
RewriteCond %/index\.php !-f
RewriteCond % !-d
# Redirect /var to /directory/index.php?id=var
RewriteRule ^.*$ /directory/index.php?id=%1 [QSA,L]
Re: .htaccess RewriteRule, ignore trailing slash
Please use example.com for examples.
RewriteRule ^(.*)/$ /directory/index.php?id=$1 [QSA,L]
to take care of the "ending in a slash case"
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
- » There's a new FAQ site geared toward Professional webmasters that's about to hit beta
- — Previous thread in » Webmaster Forum