PDA

View Full Version : HTML files forced to download



samplereality
06-16-2010, 10:24 AM
I've just updated my 3.0 account to a 4.0 cPanel account, and I'm going through some growing pains. Right now I'm having trouble with HTML and PHP playing nicely together. Basically, browsers keep trying to download any html files rather than display them.

I have Wordpress installed in my root directory, and I have this line in my .htaccess file:

AddType application/x-httpd-php .html

This worked fine under 3.0 but it's not working now. Any thoughts?

wildjokerdesign
06-16-2010, 10:36 AM
.htaccess is limited in WH 4.0. Have you looked at the interface for page types in cPanel? I need to log in to double check on exact wording but there is a way to add types via it. Let me go log in.

wildjokerdesign
06-16-2010, 10:39 AM
Found it! On the right at the very bottom under Advanced is Apache Handlers. Try using that.

wildjokerdesign
06-16-2010, 10:47 AM
Hold on... I think that you need to use server-parsed as the handler instead of application/x-httpd-php. Makes sense because in WH 4.0 PHP is runnin in cgi mode.

wildjokerdesign
06-16-2010, 10:50 AM
Ok found more info. I really wish WH would create documentation for things like this. :) It is possible that the handler would be just x-httpd-php. There are many flavors of cPanel setups and I am not 100% sure what WH is using. I don't think there are any other alternatives though. :)

samplereality
06-16-2010, 10:57 AM
Hmmm, I used the Apache Handlers tool in cPanel to force .htm and .html extensions to be server-parsed, but I'm still having the same problem.

wildjokerdesign
06-16-2010, 11:12 AM
cPanel is just adding the entry to a .htaccess file so you are right it is the same thing as what you where doing manually. Let me log in and check my WHM. I seem to recall something there about parsing php. Might be something you need to have WestHost do if you don't have a reseller account.

wildjokerdesign
06-16-2010, 11:31 AM
I am stumped. I've tried every variation I can think of and they don't work. Did not find anything in my WHM so it may have been I saw that when I was working over at VPS.net and a full version of WHM. I think you'll have to contact WestHost and ask them why the documented stuff does not work on WH 4.0.

wildjokerdesign
06-16-2010, 11:48 AM
I figured it out! It seems the handler you need to use would be application/x-httpd-php5. Now if for some reason you are running php 4 instead then I be you would need to change that to application/x-httpd-php4. PHP 5 is the default on an account. This is working for me on a test account.

samplereality
06-16-2010, 05:46 PM
It works! Thanks, Shawn! By the way, I found your tutorial (http://wildjokerdesign.net/faq/how-do-i-move-my-30-database-my-40-account) on importing Wordpress databases from WH3.0 to 4.0 very helpful as well!

wildjokerdesign
06-17-2010, 07:10 AM
Your welcome! I am glad the tutorial helped you out. While moving from WH 3.0 to WH 4.0 is not really terribly hard there are a couple things that can catch you up. I thought a few details might help folks. :) I need to remember to go add this bit of info over at my FAQ. I am glad you mentioned the tutorial.

wildjokerdesign
06-17-2010, 07:50 AM
Ok I've written up the tutorial (http://wildjokerdesign.net/faq/how-can-i-force-html-and-htm-files-be-processed-php) on this subject. I actually figured out that you can run both php5 and php4 on the same account with the use of Apache handlers. Kind of cool. I give details in the tutorial linked above.

heroofcamelot
11-29-2010, 07:38 AM
I'm on the WH 3.0 environment and I'm having this problem too. I'm in the process of updating my site to include a CSS pull-down menu on every page using PHP Includes. My site has a decent search engine ranking, so I was hoping not to have to rename every file to .php. I read on-line that I could solve this by creating a file called .htaccess in my site's root directory with the following lines:


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

But when I do this, I encounter the same problem as the poster of this message, browsers keep trying to download the webpage files, rather than display them.

I'm not sure if you guys are still around, but if you are or if anyone else here is familiar with how to do this on the WH 3.0 environment, I was wondering if anyone has found a solution to this.

Thanks in advance.

heroofcamelot
11-29-2010, 09:37 AM
Also, I just want to point out that I did try the advice on Wildjoker's page http://wildjokerdesign.net/faq/how-can-i-force-html-and-htm-files-be-processed-php but that was designed for WH 4.0 apparently, and does not work for my site. I tried changing it to application/x-httpd-php4 and application/x-httpd-php5 as he does there, and even application/x-httpd-php5.3.0, which is the version I have installed in my account. But none of these works.

wildjokerdesign
12-03-2010, 02:12 PM
In Westhost 3.0 what you have done should work. If you look at the httpd.conf file you'll see that it uses AddType application/x-httpd-php for a variety of php alternative extensions. You could try adding it to the /etc/httpd/conf/httpd.conf file and then restarting your account to see if that would do it for you. In fact if you scroll down to around lines 790 - 798 you should see the existing entries for php and you could just tack .htm and .html onto the list. Actually you only need to add the extension you use. Surely you are not mixing your site files between .htm and .html. :)