SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member
    Join Date
    Nov 2011
    Location
    United States
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do i redirect error page to home page?

    Hi Friends,

    My question is "How do i redirect error page to home page?".

    I've tried following codes in .htaccess file, but still not working for me.

    ErrorDocument 404 /index.html

    ErrorDocument 404 /error.html

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

    can anyone help me to solve this issue?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Looks like you've done the right thing, as long as the pages cited are in the root folder. Check out this thread:

    http://www.sitepoint.com/forums/show...=1#post4877347

    Are you sure you want to redirect to the home page? That's not very informative for the user. Better to land on a customized 404 page that attempts to explain what's going on.

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    LGW,

    WHICH is your Home Page?

    If it's index.html, the first ErrorDocument is good. If error.html is the Home Page (then what is the matter with you?), then the second ErrorDocument is good. If the Home Page is the DirectoryIndex of your DocumentRoot, then the third will still not work ... but only because of the leading /.

    Ralph's link is good but gets too burdensome with all the extraneous ... well, the format is ErrorDocument {status code} {absolute link} where the {absolute link} can be either external (http://yadda-yadda.com/404.php) or internal (/404.php).

    Ralph,

    Too true! However, I like posting a quick message then redirecting in x seconds to the Sitemap (or the Home Page). You're spot on saying not to redirect without a message but I don't like to leave the visitor stranded on the message page (and would rather not force the visitor to click on a link to go where I think they need to be redirected).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dklynn View Post
    I like posting a quick message then redirecting in x seconds to the Sitemap
    I tend to provide a message and a sitemap (of sorts) on the error page. Visitors might be a little taken aback at getting a message and then having the page redirect all of a sudden. Or maybe not! (I'm just thinking how I'd react.) Anyhow, I prefer an error page that gives me some idea of what my options are.

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Ralph,

    We're on the same page - except that I like to explain why a visitor was sent to the Sitemap (or Home Page) rather than displaying something they were not expecting. Minor preferential difference but my version required a little additional code.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dklynn View Post
    Ralph,

    We're on the same page
    No, you're jumping to a different one. (Or maybe not ... I'm just being cheeky.)

    I'm not sure I'd have the confidence that people would read the message in time ... but maybe I'm a slow reader. Often subtitles in films move too fast for me.

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Well, ending up on the same page?

    Yes, I give a few seconds and the message is normally very brief. Gee, even I could read that fast! It's an excellent point that I omitted, obviously. Thanks for noting that "minor detail."

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •