Forum Moderators: phranque
Now the site works fine with this line commented out. It seems to me that sometime in the past couple of hours something on the server would have been changed to cause this sudden odd behaviour. We were alerted to the problem by a customer who was on-line, and had been on the site for 30 minutes, when it suddenly started mis-behaving.
Help?
The folks at my hosting company are clueless at this point. Besides what I usually tell them, is there anything that I might suggest to them, maybe something was done and should be undone?
<add>
Now that the crisis has passed, a look under the cover reveals that the host may have made changes, either to httpd.conf, or recompiled a version of PHP (currently Ver. 4.3.5) I wish I knew what version was running yesterday...
I've assumed either of these based only on my limited research for 'application/x-httpd-php' and have no way to verify either scenario.
</add>
Can anyone offer a suggestion as to why this line forces my site to display a download box instead of a web page?
Here is the offending line:
AddType application/x-httpd-php .htm .html .php
The rest of my htaccess looks like this (without the ErrorDocument, RewriteCond or RewriteRules).
AuthName example.com
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
# AddType application/x-httpd-php .htm .html .php
(this statement is a single line)
DirectoryIndex index.html index.htm index.php php_value auto_prepend_file /home/mydomain/public_html/dir1/dir2/refer.php
<Limit GET POST>
order allow,deny
deny from xx.****.****.
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
<Files ~ "^.*$">
order allow,deny
allow from all
deny from env=ban
</Files>
gracias
I will theorize that someone long ago got confused between AddType and AddHandler, and posted his/her code, and it's been copied ever since.
So, not an answer, but another question... Is your problem really a problem? Hopefully, someone who knows can help us out.
Jim
It's possible I may be missing something
Nope, probably not. I would theorize that I read about that MIME-type somewhere and thought it was necessary. The more I look into it though, the more that I see where it seems to cause more trouble than good.
Is your problem really a problem?
Somewhere down the road I hope to discover what triggered that to start downloading instead of displaying. I still think something changed on the server, and the mime type started doing what it was supposed to do?.?
Is your problem really a problem
someone who knows can help us out
so the correct mime type on the server for the php files is the application/x-httpd-php, which you have to set in the apache config with the AddType directive, while the correct mime type for the (compiled) php files on the client side is the text/html (or text/plain or whatever the php file produces, can be image/jpeg also).
so what you've done by commenting the AddType line was that you turned off the processing of the php files, if the php was configured as a sapi module
Something must have changed on the server to break grandpa's site, and so my question is secondary, but may be important in determining the solution to his problem.
Jim
There is no need to specify php in there if it is already set up to be parsed by PHP, which it should be. The only difference I can tell between your Apache directive and mine is that I don't use the dot (.) before the file extension.
Try this in your .htaccess file:
AddType application/x-httpd-php html htm
15. Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse the .php extension as PHP. You could have any extension(s) parse as PHP by simply adding more, with each separated by a space. We'll add .phtml to demonstrate.
AddType application/x-httpd-php .php .phtml
mod_php doesn't seem to set itself up as a handler but does things like this. Which I admit doesn't seem to make much sense.
Jon.
Is PHP configured to run as a module, or in CGI mode?
Actually, this direction has been set in the PHP Apache Installation [php.net] directions...
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
If you search the
mime.typesfile, you'll notice that there is no MIME-type listed for php. I believe that is why we are instructed to use an AddType [httpd.apache.org] directive in the
httpd.conffile (or per-directory override files such as
.htaccessif necessary).
Also, gergoe has made a decent argument here. Handlers [httpd.apache.org] can either be built into the server or included in a module, or they can be added with the Action [httpd.apache.org] directive. Since PHP is not one of the built-in handlers in the standard Apache distribution, it seems the PHP developers have created a module.
On a side note...
I have a server with PHP installed as a module and I tried to create a new
Actiondirective (a few different ways, best attempt shown below) but it failed. I would guess it failed because, as gergoe stated,
Actionseems to be expecting something else, a cgi-script perhaps. Either way, the php pages will not get processed by the parser using an
AddHandlerand/or
Actioncombination when PHP is installed as a module rather than cgi.
# WARNING: THIS DOES NOT WORK!
LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler php5_module .php
Action application/x-httpd-php php5_module
Also, as gergoe alluded, the output of the php pages actually don't get tagged with the MIME-type of
application/x-httpd-php-- a requested php page is delivered with the MIME-type specified in the php script. If none has been specified in the script, I believe the reason the pages get delivered as expected (with the correct headers) is the
default_mimetypeconfiguration directive in the
php.inifile.
php.ini
; PHP's built-in default is text/html
default_mimetype = "text/html"
Is PHP configured to run as a module, or in CGI mode?
This is from my server information:
PHP 4.3.5 (cgi) (built: Apr 8 2004 16:22:53)
so what you've done by commenting the AddType line was that you turned off the processing of the php files, if the php was configured as a sapi module
Then by default, since my php files are being processed correctly without the AddType directive, php is not configured as a server api module. I'm not stating this as fact, its simply a deduction.
My understanding of the things discussed is weak, leaving me feeling vunerable right now. After I get caught up with some of my office tasks today I'll start researching everyones comments in detail. So far all I seem to understand is that there are some contradictory truths, and the key seems to be in how php is configured.
default_mimetype configuration directive in the php.ini file
phpinfo() [php.net] will give you that information.