Forum Moderators: coopster

Message Too Old, No Replies

AddHandler php is giving me 500 error instead of 404

         

supersteve3d

1:42 am on Mar 27, 2006 (gmt 0)

10+ Year Member



Hi All,

I am using the following code in my site to parse my old .htm .html pages as .php

# AddType application/x-httpd-php .php .html .htm
AddHandler php-script .html .htm

I initially did this to save the trouble of redirecting all my pages to .php renamed versions (and also google indexing).

Now I just found out that my 404 errors are being seen as 500 errors.

How do I fix this?

I ask because I have discovered that not having the correct 404 errors for missing files messes up googles sitemap validations. I wonder if I can trick google by making a custom 500 page that looks like a normal 404 error page? I'd rather fix this at the source though.

Anyone know?
Thanks.

[edited by: jatar_k at 3:40 am (utc) on Mar. 27, 2006]
[edit reason] no urls thanks [/edit]

coopster

12:43 pm on Mar 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, supersteve3d.

You've tried both of those lines (uncommented one and commented the other) and still receive a 500 error? Have you also mapped the php filename extension onto the HTML content type?

AddType [httpd.apache.org] text/html php

supersteve3d

2:35 am on Mar 28, 2006 (gmt 0)

10+ Year Member



Thanks for the reply.

Using the following lines to denote..1) 2) and 3)..

1) AddType application/x-httpd-php .php .html .htm
2) AddHandler php-script .html .htm
3) AddType text/html php

Only 2) seems to make the php work at all. for 1) and/or 3) the php does not seem to get parsed. Of course when that happens the 404 returns as normal. =)

Still no luck though. Anyone?

Thanks

supersteve3d

2:39 am on Mar 28, 2006 (gmt 0)

10+ Year Member



Also perhaps worth mentioning, I am back to using just ->

AddHandler php-script .html .htm

which makes the php work correctly for my site.

What is interesting is that a url like http://www.example.com/bogusfile (a directory/folder) returns a 404.. but a url to a file like http://www.example.com/bogusfile.html returns a 500.

Thanks

[edited by: jatar_k at 4:26 am (utc) on Mar. 28, 2006]
[edit reason] examplified [/edit]

coopster

3:19 pm on Mar 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Well, I was off base with the
"AddType text/html php"
anyway. I just read this thread again and noticed you have your pages as .htm/.html and want to keep them that way. If you wanted to use .php too, you would add php to the handler as well as the mime-type:
AddHandler php-script htm html php 
# For PHP5:
#AddHandler php5-script htm html php
AddType text/html htm html php

It's probably not necessary to have to add the htm/html to the AddType as they are likely already in force because of your mime.types file.

The way you have it right now should be working for you. The 404 error will make sense if that directory/folder doesn't exist. If it did, you would either get an index page, an index listing, or a 403 Forbidden message.

As far as the 500 error goes ... sounds like cgi. Is your web server running php as cgi?