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?

Looks like you’ve done the right thing, as long as the pages cited are in the root folder. Check out this thread:

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.

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

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.

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

No, you’re jumping to a different one. :lol: (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. :frowning:

:D:D:D 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.” :tup:

Regards,

DK