301 Redirect Certain File Extensions such as HTML to PHP


Simply enter the following code into your .htaccess file (changing the addresses in the examples below as needed) and save the changes. If there are several individual pages which have moved, just repeat as neccesary. Not sure how to access or change or .htaccess file. Read our .htaccess guide here.

 

301 Redirect from .HTML to .PHP extensions

RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php


Benefits of redirecting traffic to a specific file extension
  • Perfect if you've upgraded your website to use .php file extensions rather than .html or .htm. Please be careful with the above code though, because it will redirect every .html page to the .php version (i.e. check for iframe.html etc and anything else like this)