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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anivad
Forum Commoner
Posts: 80
Joined: Thu Apr 09, 2009 11:16 pm

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

Post 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.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

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

Post 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?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

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

Post 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.
anivad
Forum Commoner
Posts: 80
Joined: Thu Apr 09, 2009 11:16 pm

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

Post by anivad »

PHP is installed, though; simple PHP scripts run fine. It's only when they're in a html file.
anivad
Forum Commoner
Posts: 80
Joined: Thu Apr 09, 2009 11:16 pm

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

Post 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.
Post Reply