views:

39

answers:

1

I'm looking for a way to rewrite URLs only if the path doesn't exist. This isn't to handle 404s, but to redirect page URLs to a shared PHP file (ie: '/contact-us/' -> '/show_page.php?page=contact-us').

The basic redirect is easy enough to achieve, however I want to be able to override the default page by adding '/contact-us/index.php' in the site root.

Is this achievable with mod_rewrite or would I have to do something else?

+1  A: 

Just check the value of the REQUEST_FILENAME variable:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ...
Ignacio Vazquez-Abrams
Aha, thank you. I haven't read too deeply into rewrite conditions yet, I've been mastering the rules and regexp.
PeterBelm