Parse HTML As PHP Using HTACCESS File

There are times wherein you are required to parse HTML web pages as PHP. Suppose, you have older HTML web pages and you are required to add some additional functionality that can only be achieved by programming language like PHP. Will you modify each web page manually and add PHP code? This sound little impractical and monotonous task. To get rid of this exercise, you can parse HTML web pages as PHP using .htacccess file. All you need to do is, locate .htaccess file, add one of the following line according to your setup and save the file.

If your web server is using suPHP add following line in .httaccess.

AddHandler x-httpd-php .html .htm
OR

AddType application/x-httpd-php .html .htm

If apache is executing php as CGI use following.

AddHandler application/x-httpd-php5 .html .htm

If your server is using PHP5 try following. 

AddType application/x-httpd-php5 .html .htm

OR

AddHandler application/x-httpd-php5 .html .htm

If nothing works, try one of the following.

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
<FilesMatch "\.html$">
ForceType application/x-httpd-php
</FilesMatch>
AddHandler fcgid-script .html
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html
Options +ExecCGI
 AddType application/x-httpd-php .php .html
 AddHandler x-httpd-php5 .php .html

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

Do you support PHP on your Servers? If yes, is it automatically available OR do I have to request for it?

PHP is available on all our Windows shared hosting and Linux shared hosting. You just need to...

Fix :: file_load_file(): wrapper is disabled in the server configuration by allow_url_fopen

Error Message file_load_file($p_url); Severity: Warning Message: file_load_file(): http://...

Cpanel Email Account create Error: No specific error was returned with the failed API Call

Email account creation from Cpanel results in this error. Generally, this error is encountered...

What is the path to sendmail in Linux Shared Hosting?

The path to send email is /usr/sbin/sendmail. Note: It is recommended to use bulk email...

AccuWebHosting Offers PHP 7 Hosting

If you are following recent PHP developments, you must be aware of the latest PHP version (PHP 7)...