Search code examples
phpapache.htaccessadd-type

PHP in body of html not rendering


Hostgator have changed their server config recently for shared accounts. The result of which is that where html files were previously serving php now they are not. The output includes php tags showing in the source, and of course it is not rendered.

They wont help, telling me its a coding issue. Which I don't believe...

<?php echo 'test'; ?>

doesn't work.

So I can change all the html files and internal links to have php file extensions but this is tedious work. Luckily if I am forced to it is a small site.

However if I add an .htaccess instead with:

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

this should cut it right?

I then get the request throwing an open file dialog on firefox, and just still not rendering on IE... (I'm getting the error: You have chosen to open...which is: application/x-httpd-php)

Any thoughts appreciated.


Solution

  • For Hosgator, you should add the following code:

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

    Notice the the "5" after php.