homepage Welcome to WebmasterWorld Guest from 54.205.254.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Apache Custom 404 Configuration Problem
Server sends a 302
PatrickDeese




msg:1502032
 9:27 pm on Oct 24, 2003 (gmt 0)

Okay - is it me or is it the server?

I have an .htaccess file that is supposed to serve a custom 404.

[quote]

ErrorDocument 404 http://www.example.com/missing.html

[quote]

With this code, the site shows the appropriate 404 page. Except when I did a server header check, the server headers are producing a 302 found message instead of a 404.

Is that something badly configured on the server end, or have I somehow messed up something as simple as this one line of instruction.

Just for the record, the server does show 404 in the header if I remove the htaccess file.

any ideas?

 

robho




msg:1502033
 9:37 pm on Oct 24, 2003 (gmt 0)

The 302 redirect is normal when you specify a full URL.

If you intend to redirect to a page on the same domain, use the form of the page name relative to the root, i.e.

ErrorDocument 404 /missing.html

PatrickDeese




msg:1502034
 9:57 pm on Oct 24, 2003 (gmt 0)

Thank you for replying. The problem is using the entire domain name is the only way that I can actually get the correct file to be served.

I think it has something to being on a shared server? The main reason is that I don't want to serve Bots 302 responses when they are really 404s.

Is there anything that I can insert into the 404 document file to have the same effect - NoIndex, NoFollow for instance....

Or is there a better solution?

robho




msg:1502035
 10:55 pm on Oct 24, 2003 (gmt 0)

The problem is using the entire domain name is the only way that I can actually get the correct file to be served.

Do you mean the file is in the same domain, but specifying it as /missing.html doesn't work, or do you mean it has to be at a different domain? Is one domain http:// and one https://, or a different port?

The way ErrorDocument works, it WILL give a 302 if the full url is given. Specifying a filename, WITH the path from the server root, should normally work, and that's what you want to aim at getting to work - 404 with a full url won't.

You mention being on a shared server - maybe you need to add further path information in the name to ensure it goes to your directory from the server root? For example if you're [widget.com...] then your error document might be /~patrick/missing.html etc?

PatrickDeese




msg:1502036
 11:12 pm on Oct 24, 2003 (gmt 0)

By shared server - I mean a semi-dedicated server with a list of domains in the admin root, and each domain name assigned its own unique IP. ie a folder for example.com and another for example2.com etc.

The problem is that I am using the client's host to adminstrate a number of his domains so I don't exactly know much about the set up accept I have been given admin access.

When I use the htaccess file with a non-qualified url (not fully qualified URL), the server ignores the custom 404. The only way I can make it work is by using the entire domain.

I am guessing that this is something the webhost has to work out.

jdMorgan




msg:1502037
 11:21 pm on Oct 24, 2003 (gmt 0)

PatrickDeese,

> something the webhost has to work out.

It certainly sounds like it... The solutions presented here are 100% correct, and Apache specifically warns about the 302 problem when using canonical URLs for 40x errors in the ErrorDocument documentation [httpd.apache.org].

Jim

robho




msg:1502038
 10:40 am on Oct 25, 2003 (gmt 0)

I am guessing that this is something the webhost has to work out.

If it's a multi-domain virtual server then the setup can be unusual, so yes. You need to find out what prefix your missing.html needs to be reachable from the server root. It needs that prefix (e.g. /mydomain/missing.html or more) to work.

PatrickDeese




msg:1502039
 3:33 pm on Oct 25, 2003 (gmt 0)

> e.g. /mydomain/missing.html or more

I tried a few combinations but none seemed to work. My client is going to contact tech support on Monday. Thanks for the pointers.

jamie




msg:1502040
 6:58 am on Oct 27, 2003 (gmt 0)

hi patrick,

i had exactly the same error last night.

but mine worked with one virtual domain and didn't with the other!?*! ;)

(http://www.webmasterworld.com/forum92/498.htm)

i tried this morning and suddenly it worked perfectly. i did nothing to change it overnight (except dream about it a lot - subliminal persuasion? ;)

the only thing which occurs to me now is that is might have been an IE bug.

have you tried accessing your missing page with netscape or opera?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved