Forum Moderators: phranque

Message Too Old, No Replies

getting Internal Server Error rather than 404

(problem with .php not .htm)

         

brivers

6:18 pm on Jan 31, 2004 (gmt 0)

10+ Year Member



When a user incorrectly enters the name of .htm file, like bogus.htm, my custom 404 page comes up.
With an incorrectly entered .php file, like bogus.php, I get a 500 Internal Server Error.

I'm moving a site over to a new server (from static to php pages), so it's extremely important for me to catch links that may not have been updated.

My provider for the existing site was not willing to work with me to solve the problem. I would like to get ideas from the gurus here before contacting support for the new provider.

I've been through many of the "Internal Server Error" and other search results, have found many good ideas unrelated to my current problem, but didn't find anything specific on my issue.

My .htaccess file contains only the following 2 lines:
ErrorDocument 404 /files/error404.php (this works)
ErrorDocument 500 /files/error500.php (this does nothing)

As stated previously, the error404.php file does come up as expected with bogus.htm.

info for the new server:
Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_jk/1.2.0 mod_perl/1.26 PHP/4.3.3

Bill

isitreal

9:05 pm on Jan 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why not just add this line to your .htaccess file?

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

That will make the server run all your old pages using the htm or html extension but process all the php on the page, and you won't lose any pages, no 404's from the change, old links to your site will still work, etc.

brivers

9:56 pm on Jan 31, 2004 (gmt 0)

10+ Year Member



Thanks for responding isitreal,

There were major changes to the old site. Biggest: no more frames! Also changes were made to page names, image names. The site is ready to go and appears to be working fine.

I would just like my 404 custom error page to come up on a bad link or incorrectly type url.

One of my servers handles it just fine, the other one (the reason for my post) does not:

Trying looking for bogus.php on both to see what I mean.

[edited by: jdMorgan at 12:15 am (utc) on Feb. 1, 2004]
[edit reason] No personal URLs, please see TOS. [/edit]

brivers

10:17 pm on Jan 31, 2004 (gmt 0)

10+ Year Member



You mean that line of code in the htaccess file would allow php processing in an htm file? Wish I had known that a few weeks ago.

jdMorgan

12:17 am on Feb 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bill,

Welcome to WebmasterWorld [webmasterworld.com]!

If you have access to it, checking your server error log file after a 500-Server Error should tell you what or where the problem is.

Jim

brivers

1:02 am on Feb 1, 2004 (gmt 0)

10+ Year Member



This is the info found in the logs.

from access log:
[31/Jan/2004:15:54:55 -0600] "GET /bogus.php HTTP/1.1" 500 623 "-" "Mozilla ...

from error log:
[Sat Jan 31 15:54:55 2004] [error] [client 65.96.241.82] Premature end of script headers: /home/.../www/interpreters/php-script

isitreal

5:59 pm on Feb 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You mean that line of code in the htaccess file would allow php processing in an htm file? Wish I had known that a few weeks ago.

I wish I'd always known that too, it's very convenient, and also keeps the urls looking like people expect them to.

brivers

7:33 pm on Feb 1, 2004 (gmt 0)

10+ Year Member



That would be such an easy solution if it work on my new server.

I added: AddType application/x-httpd-php .htm .html
to the .htaccess file on 2 servers below (we'll call them Server 1 and Server 2).

Server 1 (it works):
Apache/1.3.26 (Unix) Debian GNU/Linux mod_ssl/2.8.9 OpenSSL/0.9.6g PHP/4.1.2 mod_perl/1.26
http://www.example.com/sshots006/test/test1.htm

Server 2 (doesn't work):
Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_jk/1.2.0 mod_perl/1.26 PHP/4.3.3 FrontPage/5.0.2 mod_ssl/2.8.12 OpenSSL/0.9.6b
http:[]b[/b]//www.example2.com/test/test2.htm
Same file with php extension works:
http://www.example2.com/test/test2.php

(Server info comes from phpInfo() > Environment > SERVER_SOFTWARE)

Server 1 parses the php code in the htm file.
This server also gives 404 error on non-existent php page.

Server 2 does not parse and the php code in visible in the source.
This server gives Internal Server Error on non-existent php page, but brings up my 404 page on htm files (which tells me that it reads my htaccess file).

Server 2's behavior is EXACTLY SIMILAR to another server I use... totally different provider.

Server 3:
Apache/1.3.26 (Unix) PHP/4.1.2 FrontPage/5.0.2.2510
(Gives Internal Server Error and the AddType to parse php in an htm page does not work.)

* So I don't know what to do, other than go with php extensions (so php gets parsed).
* Live with the Internal Server Errors (not knowing where the errors are coming from).

I'm hoping someone knows what's going on here.

[edited by: jdMorgan at 10:12 pm (utc) on Feb. 1, 2004]
[edit reason] Removed URLs per TOS. [/edit]

jdMorgan

10:09 pm on Feb 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bill,

It looks like you have FrontPage Extensions installed on server #2. If you don't need them, ask your host to move you to a server without FrontPage extensions. FP extensions and user-configured .htaccess files are mutually-incompatible.

Jim