Forum Moderators: phranque

Message Too Old, No Replies

A "Simple" 404 Custom Page & .htaccess Question

404 custom page and .htaccess

         

feralreason

10:01 pm on Jan 6, 2012 (gmt 0)

10+ Year Member



I have stripped everything out of my .htaccess but this one line:

ErrorDocument 404 /errorDocs/notfound.html

notfound.html is my custom 404 page.

In running tests:
"http://www.mysite.com/nopage.html" brings up the custom 404 page.
"http://www.mysite.com/nopage.php" brings up 1&1's default 404 page.
"http://www.mysite.com/index.htm" brings up a "Multiple Choices" error, as does any URL with any extension if the same filename.php exists.

Surprisingly (probably only to me), a URL containing a file with a similar extension, like "http://www.mysite.com/about.pp" causes the rewrite of the URL to "http://www.mysite.com/about.php".

Can anyone explain what I've done wrong ?

I apologize if this is such a beginner question. After 2 days of troubleshooting, I'm throwing in the towel. I need some direction on the most efficient way for an htaccess dummy to learn what he needs to handle custom 404 pages (and canonicalization) without going to a 4 year college on htaccess.

coopster

10:10 pm on Jan 6, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



At first glance it looks to me like there is something else in your configuration that is being overlooked or perhaps information that you are not privy to because you do not have full access to your Apache configuration files. If you are getting two different 404 pages because of a file extension then something else is looking at your extensions or mime types and processing alternative to what you expect.

feralreason

10:27 pm on Jan 6, 2012 (gmt 0)

10+ Year Member



Coopster,

Thanks - so first step is to call my hosting service and see if there is ... maybe another .htaccess file in the directory above my root (?)

But would that explain the Multiple Choices error too - or is there a separate way to handle that ?

Thanks so much for your help !

lucy24

10:37 pm on Jan 6, 2012 (gmt 0)

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



For starters: does your own site actually use more than one extension? Which ones? Did you have to set something in your host's control panel to tell it which extensions you're using?

By weird coincidence I came across something very similar just yesterday while I was testing a rewrite. Asking for something nonexistent with .htm extension-- which I don't use, and which should not have been affected by the rewrite-- brought up my custom 403 page instead of the custom 404 it should have elicited. My best guess is that the config file includes a line that changes the extension

:: detour to check ::

I think it's this:

[httpd.apache.org...] (under "multiviewsmatch")

This involves two different modules, mod_mime and mod_negotiation, working in collusion with an Options directive that explicitly includes MultiViews (which is off by default, even if you say Options +All).

:: looking vaguely around for g1smd ::

Not sure how it applies to files that don't exist at all, but it's my best guess.

feralreason

10:48 pm on Jan 6, 2012 (gmt 0)

10+ Year Member



lucy24,

I'm only using 1 extension. Don't remember going through a configuration that restricted me to that. This is my client's 1&1 - standard hosting pkg - and as I recall 1&1 doesn't have much in the way of configuration options (or I haven't found which rock in the control panel they are hiding under.)

By the way, the same code works great on one of my goDaddy sites -- no Multiple Choices, no problems with php extensions.

So my next step (after my nightly treadmill) is calling 1&1 / further exploration of the control panel.

I'll be back :)

Thanks much !

g1smd

11:22 pm on Jan 6, 2012 (gmt 0)

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



Turn off MultiViews and other similar options.

lucy24

2:24 am on Jan 7, 2012 (gmt 0)

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



If you're on shared hosting, you don't and can't see the config file. But its settings will affect you, so you may need to override them. Assuming you're allowed to.

"You" = your client's site ;)

feralreason

4:41 pm on Jan 7, 2012 (gmt 0)

10+ Year Member



g1smd, lucy24 - I changed my .htaccess to read:

Options -MultiViews
ErrorDocument 404 /errorDocs/notfound.html

And ran the same 3 tests again:

Got exactly the same results.

Calling 1&1 support to get further info. Be back ...

Thx again for all the support :)

feralreason

6:12 pm on Jan 7, 2012 (gmt 0)

10+ Year Member



Just got off the line with 1&1. They tried to convince me that this was a feature - lol ! 1&1's FAQ indicates that parking pages have to be disabled but the link to do that has been removed from the control panel (domains). So (the nice lady from India patiently explained) ../*.php always goes to their default 404 page and ../index.htm goes to "Multiple Choices". (By the way -- this .htaccess file works seamlessly in my goDaddy account.) I did manage to convince them that this is not a feature - it is a problem and it may be having other side-effects. They'll research it ... sad.

g1smd

7:29 pm on Jan 7, 2012 (gmt 0)

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



This is typical of the sort of junk you have to put up with when you host with GoDaddy, 1&1, FastHosts, etc.

feralreason

7:58 pm on Jan 7, 2012 (gmt 0)

10+ Year Member



Actually, I've had great support from GoDaddy -- perhaps it's just the luck of draw on the support folks I've gotten to talk to. I actually went to goDaddy because of the poor experience I was having at 1&1. But, as I said, I also had no .htaccess problems with the goDaddy accounts...

feralreason

2:47 am on Jan 8, 2012 (gmt 0)

10+ Year Member



Think I've got the solution - for 1&1.

1) Delete the "ErrorDocument 404 /errorDocs/notfound.html" line from the .htaccess file.
2) Rename "notfound.html" to "error404.html" and move it to the root directory.

That makes us go to the custom error document when the URL is ../nopagethere.php.

3) Add "CheckSpelling Off" to the .htaccess file. That prevents the 300 Multiple View errors. So now I get the custom 404 error file for all 3 tests :) (Hat's off to my son for coming up with this.) :)

Not sure why 1&1 support couldn't suggest the first 2 items above.

feralreason

2:49 am on Jan 8, 2012 (gmt 0)

10+ Year Member



Meant "300 Multiple Choices", not "300 Multiple View"...