Rewrite only URLs that don't exist

Posted by PeterBelm on Stack Overflow See other posts from Stack Overflow or by PeterBelm
Published on 2010-04-28T12:35:46Z Indexed on 2010/04/28 12:43 UTC
Read the original article Hit count: 157

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?

© Stack Overflow or respective owner

Related posts about apache2

Related posts about mod-rewrite