views:

22

answers:

1

Here is my rule:

RewriteRule ^(.*)\.html$ /$1.php

This works for "virtual" .html urls which have a matching physical .php file on the server.

However when I type in a url for an actual .html file, I cannot access it, because of course the rule above is telling the server to look for a physical .php file.

So how can the rule be modified to apply to URLs only if there is a physical .php file, else load the .html file as is.

+2  A: 

Try this rule:

RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)\.html$ /$1.php
Gumbo