Redirect HTML extension to PHP

It’s very easy to redirect requests to .html pages to .php pages. You will need to add some lines to the .htaccess file. If this file doesn’t exist in your directory then you must create it.

The two lines are:

RewriteEngine On
RewriteRule ^(.*).html$ /$1.php [L,R]

Now, HTML files will be redirected to php files. E.g. https://domain.com/test.html will be redirected to https://domain.com/test.php

htmltophp
Redirect *.html to *.php

To test .htaccess code you can use https://htaccess.madewithlove.be/

Leave a Reply