Wednesday, September 4, 2013

GoDaddy - Configuration to allow PHP in HTML files

I had an existing site with a lot of existing html files that also needed to execute php. However, when configuring anything, there may be numerous ways to solve the same problem. You can find this question on many sites and some solutions work for people and some do not. I found I had to keep trying slightly different versions until one finally worked. It all depends on the particular hosting service you are using, the various settings your particular site has..on and on.
On my local server, I could put the following at the top of my .htaccess file and it ran the php inside the .html files fine:
AddHandler x-httpd-php .php4
AddType application/x-httpd-php .html
On the GoDaddy server, the configuration was a bit different:
Options +ExecCGI
AddType text/html .html
AddHandler x-httpd-php5 .php .html
I had struggled with this for awhile, this article gave me the best hint:
http://www.sandisviksna.com/blog/2011/10/16/php-in-html-with-godaddy/
which recommended this:
Options +ExecCGI
AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php5 .php .htm .html
So I kept tweaking that and it worked. Honestly, I have not completely read the Apache manual on what exactly these directives mean. I am one of those people that is willing to use what works without really knowing the details because I have to keep working. The client want stuff done and right now I do not have the leisure time to research the details...I hope this helps someone else!

No comments:

Post a Comment