Forum Moderators: phranque

Message Too Old, No Replies

htaccess PHP problem

         

ratman

12:05 am on Dec 3, 2006 (gmt 0)

10+ Year Member



I have just moved all of my websites to a new hosting company and immediately noticed that some of the sites seemed to run extremely slow which I eventually traced back to the "AddType application/x-httpd-php .htm .html" entry in the htaccess file, when that line is removed the site immediately returns to full speed again. I have asked the hosting company (who have been fantastic so far) but they cannot work out why the problem exists and have contacted Direct Admin (the control panel software company) to see if they can help and are awaiting their response. Has anybody else experienced this problem, if so what was the cause.

Thank you in advance for any help.

jdMorgan

12:26 am on Dec 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer appears to be that with certain configurations, this directive forces all html and htm files to be parsed for PHP includes. This despite the fact that AddType is only supposed to set the MIME-type to be sent back to the client in the response headers, along with the page content, and that AddHandler is really the correct directive to force server-side script parsing.

Jim

ratman

1:56 am on Dec 3, 2006 (gmt 0)

10+ Year Member



Hi Jim, thanks for your reply. What would be the correct code to put into the htaccess instead?

cduke250

12:47 pm on Dec 4, 2006 (gmt 0)

10+ Year Member



It could be that, or it could be that your web host wants you to use the cgi'd version of php.

A lot of hosts have all kinds of security features enabled when you use the mod_php and the cgi'd version is much faster in some cases.

Take a look at these examples from the askapache site.


### RUN PHP AS APACHE MODULE ###
#AddHandler application/x-httpd-php .php .htm

### RUN PHP AS CGI ###
#AddHandler php-cgi .php .htm

### CGI PHP WRAPPER FOR CUSTOM PHP.INI ###
#AddHandler phpini-cgi .php .htm
#Action phpini-cgi /cgi-bin/php5-custom-ini.cgi

### FAST-CGI SETUP WITH PHP-CGI WRAPPER FOR CUSTOM PHP.INI ###
#AddHandler fastcgi-script .fcgi
#AddHandler php-cgi .php .htm
#Action php-cgi /cgi-bin/php5-wrapper.fcgi

### CUSTOM PHP CGI BINARY SETUP ###
#AddHandler php-cgi .php .htm
#Action php-cgi /cgi-bin/php.cgi