homepage Welcome to WebmasterWorld Guest from 54.145.209.80
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
.htaccess file
How do I make a custom 404 error redirection?
lizzie

10+ Year Member



 
Msg#: 505 posted 2:52 am on Mar 29, 2001 (gmt 0)

I just got my new hosting service and would like
to know how to make a custom 404 error redirection?
Someone told me how but it didn't work, so I'm hoping
for another response!

 

Froggyman



 
Msg#: 505 posted 3:48 am on Mar 29, 2001 (gmt 0)

In that same .htaccess file you create add this:

ErrorDocument 404 /notfound.html

Replace notfound.html with the name of the file you want visitors redirected to.

lizzie

10+ Year Member



 
Msg#: 505 posted 5:47 am on Mar 29, 2001 (gmt 0)

Thanks, it worked like a charm. When I make up a page for instance www.mydomain.com/fakepage.html it goes to the right page but it shows the name of the page I made up in the address bar.
Also I have this in my error logs:
[Thu Mar 29 00:12:42 2001] [alert] [client 487.438.385.78] /htdocs/users/me/myname/myname/mydomain.com/.htaccess: AllowOverride not allowed here
[Thu Mar 29 00:28:54 2001] [error] [client 487.438.385.78] Directory index forbidden by rule:
/htdocs/users/me/myname/myname/mydomain.com/

I had tried the AllowOverride and it messed things up real bad
in my webshell so I couldn't access it for a few hair-raising minutes. Is it trying to tell me something?

Gorufu

10+ Year Member



 
Msg#: 505 posted 10:16 am on Mar 29, 2001 (gmt 0)

Hi Lizzie, hope this helps

> When I make up a page for instance www.mydomain.com/fakepage.html it goes to the right page but it shows the name of the page I made up in the address bar.

That's normal. A 404 error is produced for fakepage.html

--------------------
> /htdocs/xx/xx/mydomain.com/.htaccess: AllowOverride not allowed here

The above should have created a 500 Internal Server Error. AllowOverride is not allowed in .htaccess

It is used in the main Apache httpd conf files, usually in access.conf or httpd.conf

--------------------
> Directory index forbidden by rule:

This would have created a 403 Forbidden access error and occurs if there is no default index page eg index.html

To allow directory listings when there is no default page add to your .htaccess file

Options Indexes

Also you should be able to change the default index page by adding to .htaccess

DirectoryIndex index.php3 index.htm index.html default.htm

Using the above example if there is no page specified in the URL eg "http://www.domain.com" Apache will look for index.php3. If index.php3 does not exist it will look for index.htm and so on.

---------------------
It is a good idea to check that .htaccess cannot be viewed in a web browser "http://mydomain.com/.htaccess"

If you get a Forbidden access error it's protected. If the browser displays a listing of your .htaccess file add the following to it.

<Files .htaccess>
deny from all
</Files>

lizzie

10+ Year Member



 
Msg#: 505 posted 12:15 pm on Mar 29, 2001 (gmt 0)

Thanks! I'm looking at a competitor's page and when I go to www.herdomain.com/fakepage.html
(a page name on her domain I made up) the URL in the address bar changes to www.herdomain.com,
rather than showing the made-up page name.

Gorufu

10+ Year Member



 
Msg#: 505 posted 1:23 pm on Mar 29, 2001 (gmt 0)

Your competitor is probably using the full URL.

ErrorDocument 404 [herdomain.com...]

I would not recommend using full URLs for 404 errors. They are treated as 302 redirects and could cause problems or get you banned with search engines.

Whenever a full URL is used it becomes a 302 redirect.
ErrorDocument 404 [yourdomain.com...]

I learnt the hard way. The best practice is to use relative paths only for 404 errors.

ErrorDocument 404 /missing.html
ErrorDocument 404 /errors/missing.html

Edited by: Gorufu

lizzie

10+ Year Member



 
Msg#: 505 posted 2:05 pm on Mar 29, 2001 (gmt 0)

Thanks, much appreciated!
My competitor does a lot of no-nos with fantastic results
on Google at least.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
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