This site runs best with JavaScript enabled.

HTML Files Parsed Through PHP

HTML Files Parsed Through PHP HTML Files Parsed Through PHP

Photo by Chris Lao on Unsplash

In the past I have used mod_rewrite to redirect .html file request to the equivalent .php file names. For example:

RewriteRule (.+)\.html? $1.php

The above code would redirect any page name page.htm or page.html to page.php.

But what if you had .html or .htm file that you actually wanted to run through the php processor? Try this in your .htaccess file:

AddType application/x-httpd-php .php .htm .html
Share article
Dustin Davis

Dustin Davis is a software engineer, people manager, hacker, and entreprenuer. He loves to develop systems and automation. He lives with his wife and five kids in Utah.