views:

256

answers:

2

I have this RewriteRule that works too well :-)

RewriteRule ^([^/]*)/$ /script.html?id=$1 [L]

The bad thing about this rule is that it also matches physical directories which I don't want.

How can I tell the mod_rewrite to ignore physical directories and apply the above rule only when the directory matched does not exist?

Thanks in advance

+3  A: 

Take a look at RewriteCond. Put the following before your rule to exempt out directories and files

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
ctcherry
Thanks a lot, it works great!!!Thanks for all the answers, and thanks Joel for creating this great Site :)
Jeff Atwood et al. did the site. Joel is only his sidekick ;-)
David Schmitt
A: 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/$ /script.html?id=$1 [L]
daniels