.htaccess RewriteRule, ignore trailing slash

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm hoping you guys can help me figure this one out. I'm rewriting

To this:

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

Quoted text here. Click to load it

Please use example.com for examples.

Quoted text here. Click to load it

RewriteRule ^(.*)/$ /directory/index.php?id=$1 [QSA,L]

to take care of the "ending in a slash case"
followed by:

Quoted text here. Click to load it

John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development

Site Timeline