homepage Welcome to WebmasterWorld Guest from 54.163.72.86
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

    
404 page not found
Cosmin




msg:1500846
 7:13 pm on Oct 26, 2003 (gmt 0)

Hi,

Please tell me what do I have to add in my .htaccess file so when somebody looks for a page on my website that doesn't exist, to be redirected to an html error page (that I customize) instead of the standard 404 page not found.

Right now my htaccess file looks like this:

# -FrontPage-

IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName mydomain.com
AuthUserFile /home/httpd/vhosts/mydomain.com/httpdocs/_vti_pvt/service.pwd
AuthGroupFile /home/httpd/vhosts/mydomain.com/httpdocs/_vti_pvt/service.grp

[edited by: rcjordan at 7:36 pm (utc) on Oct. 26, 2003]
[edit reason] changed to generic domain [/edit]

 

Craig_F




msg:1500847
 7:35 pm on Oct 26, 2003 (gmt 0)

this should work:

ErrorDocument 404 [YourDomain.com...]

jdMorgan




msg:1500848
 9:21 pm on Oct 26, 2003 (gmt 0)

Uh-oh...

If you specify a canonical URL in ErrorDocument, the server will respond to requests for missing pages with a server status of 302-Found, not 404-Not Found. This can really screw up search engine listings.

Do not use a full URL -- use a local path only!

ErrorDocument 404 /YourCustomErrorPage.htm

The Apache documentation warns about this potential problem in the footnotes at the bottom of the ErrorDocument [httpd.apache.org] page. This "feature" of Apache's ErrorDocument implementation is the single most common problem with custom 404 pages, and can lead to duplicate-content problems and messed-up listings in search results.

Jim

BlueSky




msg:1500849
 11:09 pm on Oct 26, 2003 (gmt 0)

This has nothing to do with your 404 question, and that's already been answered here. I'm just curious...can you explain what this directive is intended to do?

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>

Why did you use both deny from all and allow from all?

Cosmin




msg:1500850
 2:08 pm on Oct 27, 2003 (gmt 0)

So please somebody tell me how is it?

ErrorDocument 404 [YourDomain.com...]

or

ErrorDocument 404 /YourPage.htm

kevinpate




msg:1500851
 2:56 pm on Oct 27, 2003 (gmt 0)

Go with the latter, as jdMorgan suggested in message #3.

When Jim writes, I take heed. His expertise has proven its value to me several times over.

[side bar] albeit belated, Congrats on the mod gig Jim.

Hagstrom




msg:1500852
 3:17 pm on Oct 27, 2003 (gmt 0)

Is that all there's to it? Two days ago I made a .htaccess file consisting of one line (i.e. the entire file was 26 bytes):

ErrorDocument 404 /404.htm

It worked fine on my own Windows XP (Apache with Localhost) but when I uploaded it to my ISP, I got a 500 server error.

BlueSky




msg:1500853
 4:27 pm on Oct 27, 2003 (gmt 0)

Sometimes 500's are caused by uploading the file in binary instead of the required ascii. You can also get them from syntax/typographical errors and non-printable characters. If that is all you have in the file, then it's not the former. To avoid the latter, make sure you use a text editor that doesn't add extra hidden characters.

If after checking these you still get a 500, then try adding this directive above the ErrorDocument one. Some servers need it for certain directives and others don't. Not sure why.

Options +FollowSymlinks

[edited by: jdMorgan at 7:48 pm (utc) on Oct. 27, 2003]
[edit reason] Edited typo at poster's request [/edit]

jdMorgan




msg:1500854
 8:03 pm on Oct 27, 2003 (gmt 0)

Another thing that can cause problems is that ErrorDocument requires that AllowOverride All or AllowOverride FileInfo be set (granted) by your hosting provider. If it's still not working, you might want to check with your host about this. The AllowOverride setting should be in the server's httpd.conf file.

Jim

Cosmin




msg:1500855
 10:35 pm on Oct 27, 2003 (gmt 0)

Jim,

I have a site protected with a user name and password. This site it's hosted on an old server and I want to transfer it on my new dedicated server. (with no downtime or unprotected)

the htaccess file looks like this:

# -FrontPage-

IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
require valid-user
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthType Basic
AuthName mysite.com
AuthUserFile /home/virtual/site13/fst/var/www/html/_vti_pvt/service.pwd
AuthGroupFile /home/virtual/site13/fst/var/www/html/_vti_pvt/service.grp

I made a copy of this site and uploaded on the new server. The htaccess of the new site is identical with the other one:

Also I uploaded the htpasswd from the old site (same password file) and put it in the root (as on the other site)

Now, when I try to access the site on the new server it ask me for a user name and password but it doesn't accept the password.

Could you please guide me on this?

jdMorgan




msg:1500856
 12:00 am on Oct 28, 2003 (gmt 0)

Cosmin,

This is a new subject and deserves a new thread, I think...

> Also I uploaded the htpasswd from the old site (same password file)

I don't think this will work -- You will probably need to create new encrypted passwords for use on the new server. The "seed" used to encrypt passwords differs from server to server, and the old encrypted passwords will not be valid on a different server.

You can use the same clear-text passwords, but they will need to be re-encrypted and saved in a new .htpasswd file.

Jim

Hagstrom




msg:1500857
 10:24 am on Oct 28, 2003 (gmt 0)

BlueSky:
try adding this directive above the ErrorDocument...

I will try that (unfortunately I can't update my site at the moment). Anyway, I was wondering whether some kind of wrapper / header was needed, and you have just answered that one for me. Thanks.

jdMorgan:
ErrorDocument requires that AllowOverride All or AllowOverride FileInfo be set

I could ask my ISP, but I thought the server would simply ignore the un-allowed statements, rather than give me a 500.

closed




msg:1500858
 12:22 pm on Oct 28, 2003 (gmt 0)

I know this is probably obvious, but whenever you get a 500 error, you should try checking your server's error logs.

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