Is there a way to use htaccess to make all html pages forward to a php version?

Kyle

New member
I want to make all html pages on the site forward to a php version with the same name, just the different extension. F.E. "page.html" would forward to "page.php" and so on.... I tried using .htaccess to make all html pages be able to have php on them, but that didn't work (maybe because of my server), but saving files as php works but I still want old back-links, etc to work. Thanks!
 
You don't say what web server you are using but if you are using Apache you need to look at mod_rewrite to do what you need...

It will be a simple rewrite rule to change anything ending in .html to .php

Rewrite on
RewriteRule ^(.*)\.html$ $1.php [R=301,L]

The R=### is the response code... 301 being permanently moved.. which I believe is what you want.
 
Back
Top