Parse PHP In HTML Godaddy

Why would I want to parse PHP in HTML files?

For example let’s suppose you have dozens of html files that have the exact same navigation or footer. When you update the menu you don’t want to go and edit all the static HTML pages of your website. So you use an include that will add the menu from a PHP file, and when the menu needs to be changed you will only have to update the php file.

<html>
<head>
</head>
<body>
<div>
<?php include(“menu.php”); ?>
</div>
</body>
</html>

Sometimes, in order to use this awesome php inclusions you need to tell your apache web server that html files can have php code in them, in other words to parse php in html files. This can be achieved by adding some code to the .htaccess file. This file can be found in the www directory that will most commonly be found at this path:

/home/[user-name]/public_html

If the .htaaccess file is not there, create a blank text file using your favorite text editor (mine is PSPad) and upload it to the www folder after adding the following lines in .htaccess:

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

Make sure the filename contains the dot!

 

Parsing PHP In HTML when using Godaddy Hosting

Even though I prefer HostGator, I have used Godaddy’s hosting many times, and have had difficulties trying to parse PHP in HTML with Godaddy. But I have recently discovered what the contents of the .htaccess file have to be when using Godaddy:

Options +ExecCGI
AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php5 .php .htm .html

 

10 Comments

  1. Srikanth Vasa -  2016/09/14 - 5:57 AM

    After 2 days of struggle, adding following lines worked for me:
    Options +ExecCGI
    AddHandler fcgid-script .html
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html

    If you are including any .shtml files thrugh PHP include directive in your html code then add .shtml in AddHandler:
    AddHandler fcgid-script .html .shtml

  2. Vasile -  2015/10/25 - 6:13 AM

    On Whois Hosting (whois.com) I copy this 2 rows on .htaccces, and works very good

    AddHandler fcgid-script .html
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html

    ————–
    Test it on http://neculaifantanaru.com

  3. Shanfeng Cheng -  2015/09/16 - 10:35 PM

    Tried all other solutions. None worked. I am using a dedicated server with godaddy which uses centos and plesk control panel. Here is the final solution I’ve found:

    SetHandler fcgid-script
    FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .htm
    Options +ExecCGI
    allow from all

    This information is adapted from the following information contained in /var/www/vhosts/yourdomain.com/conf/last_httpd.include for the .php extension:

    SetHandler fcgid-script
    FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
    Options +ExecCGI
    allow from all

  4. Justin -  2014/10/25 - 12:39 PM

    Thank you!! I tried forever to make this work and couldn’t find any information that actually helped. This worked perfectly!

  5. Sagar Nangare -  2014/05/09 - 7:14 AM

    Now Godaddy’s PHP version is updated to 5.4. Switching to 5.4 will affect this setting? OR above tricks works with PHP 5.4?

    Thanks

  6. dsfg -  2014/02/13 - 6:15 AM

    as of 2014, If you have a godaddy deluxe edition (linux) here is the .htaccess file that will allow you to parse php into html files (using include/require)

    AddHandler fcgid-script .html
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html

    hope it works out for you.

    • Telluride -  2014/04/08 - 12:34 PM

      I tried what you recommended and it works but not they way it is supposed to work.
      works, nevertheless, any embedded HTML is not displayed at all. Any ideas?

    • Kumar -  2015/05/16 - 4:33 PM

      This method works perfect with Godaddy hosting.. have tried nearly every other methods and didn’t work for me.. thank you very much..

    • Edward -  2015/08/23 - 11:33 PM

      Thanks! It’s work!

    • Joseph -  2016/06/03 - 3:46 PM

      Works like a charm!!! Days wasted fixed in seconds!!!!

Leave comment

Your email address will not be published. Required fields are marked *