Page 1 of 1

HTML pages not rendering PHP, and Firefox wants to save them

Posted: Wed May 18, 2011 1:30 am
by anivad
I recently shifted a site to a new webhost; everything was working fine previously, but now:

1) Whenever I try to access one of the html files in Firefox, a popup appears saying 'You have chosen to open (filename) which is a: Firefox Document'. A friend got the same result, so it's not just me.

2) The .htaccess file I uploaded to the root directory currently contains:

Code: Select all

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
On all my other sites (different webhost), this works fine and parses the php code in html pages. It's not working on this host.

Any help would be great, thanks! I've tried searching around but haven't found any answers.

Re: HTML pages not rendering PHP, and Firefox wants to save

Posted: Wed May 18, 2011 4:56 am
by social_experiment
It could be that php is not installed on the server, and with the .htaccess treating all files as .php firefox tries to save them. What happens if you run a simple php script on the server?

Re: HTML pages not rendering PHP, and Firefox wants to save

Posted: Wed May 18, 2011 8:07 am
by Weiry
Agreed, the reason for this is because php is either not installed on the server, or is not loaded by apache.
Both causes you should check with your hosting provider to make sure that they provide those services.

If they do and you are using a cPanel or DirectAdmin for management, i think they contain a way to either install or enable php.
Just have a quick check and/or ask your hosting provider.

Re: HTML pages not rendering PHP, and Firefox wants to save

Posted: Wed May 18, 2011 11:27 am
by anivad
PHP is installed, though; simple PHP scripts run fine. It's only when they're in a html file.

Re: HTML pages not rendering PHP, and Firefox wants to save

Posted: Wed May 18, 2011 6:10 pm
by anivad
It's all right, I found the solution - apparently sites hosted with GoDaddy require a slightly different line in the .htaccess file for php parsing to work.

I changed it to

Code: Select all

AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php5-cgi .html .htm
and it's working now.