Home >Backend Development >PHP Tutorial >How Can I Make Apache Treat HTML Files as PHP Files Using .htaccess?
How to Use .htaccess to Run HTML Pages as PHP Files
Need a quick solution to run all your HTML files as PHP before a presentation tomorrow? Don't fret; Apache has a solution for you.
(Answer)
To make all .html files run as .php files using Apache, follow these steps:
1. Create a .htaccess File
2. Add the Directive
AddType application/x-httpd-php .html .htm
If you're running PHP as CGI, use this instead:
AddHandler application/x-httpd-php .html .htm
Example:
AddType application/x-httpd-php .html .htm
This directive tells Apache to treat all files with the extension .html or .htm as PHP files.
Note: If you're using PHP5, you may need to replace "x-httpd-php" with "x-httpd-php5" in the directive.
The above is the detailed content of How Can I Make Apache Treat HTML Files as PHP Files Using .htaccess?. For more information, please follow other related articles on the PHP Chinese website!