-1

In case the user entry to an "unavailable site" within a website, the "http error 404" happen!!!, how to redirect a webpage with the "http error 404" to the default webpage automatically?

Is it possible?, when the HTTP status is 404, the webpage redirect itself automatically to the default page without click any button.

Charnstyle
  • 93
  • 7
  • I read from some post, it is about to use ".htaccess" file to redirect the url. but where should I put this file in? which folder? – Charnstyle Oct 23 '15 at 13:24

1 Answers1

0

Check the HTTP status if it is 404 then redirect to your default page.

How to check HTTP status code.

Redirect to your default webpage using:

    window.location = "your-default-webpage.html";
Community
  • 1
  • 1
Rahul Desai
  • 15,242
  • 19
  • 83
  • 138
  • how to redirect to the default page? – Charnstyle Nov 11 '14 at 09:10
  • Is it possible?, when the HTTP status is 404 the webpage redirect itself automatically to the default page without click any button. – Charnstyle Nov 11 '14 at 10:48
  • @charnstyle Yes. I suggest you to read up on basics of HTML and Javascript. Then it will be easy to do this task. What I have mentioned in the answer are the keys to achieve what you want. – Rahul Desai Nov 11 '14 at 11:32
  • @RahulDesai, how is someone supposed to use `window.location`, a JavaScript property, on a page which doesn't exist? By definition you can't run JavaScript if you don't have a page. This will have to be handled by something server-side to redirect the user. – Sam Hanley Nov 11 '14 at 16:19