Welcome to WebmasterWorld Guest from 107.21.159.218

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

404 page not found

     

Cosmin

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

10+ Year Member



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

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

10+ Year Member



this should work:

ErrorDocument 404 [YourDomain.com...]

jdMorgan

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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

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

10+ Year Member



So please somebody tell me how is it?

ErrorDocument 404 [YourDomain.com...]

or

ErrorDocument 404 /YourPage.htm

kevinpate

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

WebmasterWorld Senior Member 10+ Year Member



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

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

10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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

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

10+ Year Member



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

Featured Threads

Hot Threads This Week

Hot Threads This Month