1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

HTML How to make a custom "404 error" page!

Discussion in 'Web Development' started by ishkey, Jul 5, 2008.

  1. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    How to make a custom "404 error" page!


    A "404" is an error message you get when you follow a link to a web-page that doesn't exist or the server hiccups. By default this error message is a web-page created by your web-host provider. You can find it in the root folder of your public directory.

    404 Not Found
    The requested URL does not exist
    .


    Insead of your server generating the page, you can customize this web-page? This will keep you from losing viewers when you delete a page or mess up a link ... funneling those "lost souls" back into your site. This is especially important for search engines ... you don't want to lose all that SE traffic when you move a page!

    Directions:

    Open a text editor (Windows notepad will do), and copy the following onto the first line:

    ErrorDocument 404 /error-page.html
    or
    ErrorDocument 404 /sitemap.html (make sure you have a sitemap for this one)

    Now, save the file onto your hard-drive as a text file (.txt) and name it ".htaccess.txt". Yes, I know that is a weird file name, but that first period is necessary. We'll rename the file after we upload it.


    FTP to your web-site's root directory (where your homepage is located). Copy the above file into the main directory of your site.
    note: Be sure to upload in "ascii" and not "binary" format.


    Rename ".htaccess.txt" to plain old ".htaccess"


    Finally, create a custom web-page with your html editor, name it "error-page.html" or "sitemap.html", and upload it into your root directory.
    That should do it! Now when vistors get lost, they can find their way back to your home.

    If you already have a .htaccess file just add the line
    ErrorDocument 404 /error-page.html
    or
    ErrorDocument 404 /sitemap.html
    to it, and save it.

    Be sure to load your custom page.
     
  2. locksmiths

    locksmiths New Member

    Error 404

    I tried the same process and it did work for me. Thanks
     
  3. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    You must have done something wrong, as I checked to see what kind of error page you have. It turns out it is still generatered by the server.
    Your viewers might just go away.
    Look at the attached graphic - I entered http://www.aulocksmiths.com.au/junk and this is what I got.
     

    Attached Files:

    • lock.jpg
      lock.jpg
      File size:
      29.2 KB
      Views:
      5,215
  4. locksmiths

    locksmiths New Member

    Error 404 working

    Thank you so much it is working now. But i faced one problem during uploading .htaccess.txt. Whenever I was uploading that file from my local to my server it was deleted automatically. The file would not stay there. That was little amazing. I don't know why?
    Then What I did was I uploaded "htaccess.txt" without "." on the file name and then i uploaded it to my server then i renamed that file into ".htaccess"
    And it worked.

    aulockmiths.com.au/junk will now will be redirected to sitemap.html

    Thank you so much once again. I will test it for my other sites too.
     
  5. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    nope not yet.
    here is part of my .htaccess file, i send them to oops.html which is in the root directory, then oops.html sends them to my site map after 5 seconds with a meta refresh. The 5 in that line of code is seconds.
    try it http://www.cleandeck.net/junk
    your welcome to use it and mod it to fit.
    I like this two step method as the viewer gets an idea what has happened and comforts them.

    Some servers are like that when trying to upload the .htaccess file.
    Most are like yours - you nowshould be able to download/ upload the file without renaming.
    You know you can have more than one .htaccess file. You can make one for different directories to perform different tasks.
     
  6. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    seems to be working now - but wow I really tried to find my way with you sitemap, what the heck was google thinking when it generated that for you, i would redo it with your Main Menu links after all it is for people not machines.
     
  7. locksmiths

    locksmiths New Member

    Thank you so much for advancing my knowledge with .htaccess file. But now you added two more interesting fact about it.
    1) Displaying an proper error page and targeting it to any page we desire.
    2) Creating different .htaccess file for different directory. This is cool

    I will test both of this and tell you.
     
  8. Urbanrestro

    Urbanrestro New Member

    Its always better to do a 301 redirect when there is a 404 error coming up. This is done to protect the website from copy content issue which can harm your rankings or create a specific page when a 404 error comes up like its done with my website
     
    Last edited: Sep 18, 2014
  9. daviddakarai

    daviddakarai Member

    I tried the same process and it did work for me. Thanks to giving information
     
  10. Bruce Kenway

    Bruce Kenway New Member

    404 error appeared when a follow link is not existed, search engine spiders will be unable to index this link so it affects search engine result directly. Dont know why but your post is good and it really works, but could you please edit your font size to be larger?
     
  11. winzy512

    winzy512 New Member

    404 error is smt that really annoys me
     
  12. Hello Dear

    - 404 mistake and some other guru sounding talk underneath.
    - What is much more gooey about mistake code is that it rally doesn't let you know what the issue is.
    - Basicaly you have been educated that the server can not discover what you need.
    - It Doesn't let you know why,how to alter it.
    - Yet then you see it a server that is start up with its own particular unique 404 mistake page that politely statements of regret and offers you connections to email site administrator and perhaps a web crawler.
     
  13. nidhivyas

    nidhivyas Member

    404 is page not found error
    You see it a server that is start up with its own particular unique 404 mistake page .
     
  14. nidhivyas

    nidhivyas Member

    404 is page not founds Error
    The requested URL does not exist.
    A "404" is an error message.
    you get when you follow a link to a web-page that doesn't exist or the server hiccups.
    By default this error message is a web-page created by your web-host provider.
    You can find it in the root folder of your public directory.