Home >Backend Development >PHP Tutorial >How Can I Temporarily Serve .html Files as .php Files Using .htaccess?
Serving .html as .php with .htaccess
In a situation where it's not feasible to manually update all .html files to run as .php before a presentation, you can leverage Apache's .htaccess file to achieve this temporarily.
To do this, you need to:
[Apache2 @ Ubuntu/Debian:] AddType application/x-httpd-php .html .htm
[PHP5:] AddType application/x-httpd-php5 .html .htm
[PHP as CGI:] AddHandler application/x-httpd-php .html .htm
With this setup in place, all .html files within your website will be interpreted and processed as .php files. This provides a quick and temporary solution to run your .html pages as .php without modifying their file extensions or content. Remember, this is a workaround and not a permanent solution.
The above is the detailed content of How Can I Temporarily Serve .html Files as .php Files Using .htaccess?. For more information, please follow other related articles on the PHP Chinese website!