?
Solved

How to load a different Page if a page can not be found (404)

Posted on 2004-04-23
5
Medium Priority
?
176 Views
Last Modified: 2010-04-09
I would like to find out how to Load a Local page if the the page I requested server in not online

Example:
If I requested:

http://myxp.sytes.net/private/private.htm

If Not found or a error 404 then:
load a local Page:
notfound.htm

0
Comment
Question by:realredneck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 172 total points
ID: 10902074
It depends on server....
for example in IIS.

The page location is usually,
C:\WINDOWS\help\iisHelp\common\400.htm

you can specify the 404 file in the server settings... and modify accordingly
0
 
LVL 10

Assisted Solution

by:eeBlueShadow
eeBlueShadow earned 164 total points
ID: 10902090
The easiest way to do this, if your server admin has allowed it, is by using a .htaccess file (assuming the server is running Apache)

create a file called .htaccess containing the following line

ErrorDocument 404 /path/from/root/to/notfound.htm

or add the line to the bottom of an existing .htaccess file if there's already one in the directory. If you get a Server Error 500 when you try to view any page in that folder, then the server is set up not to let you do things like setting individual error pages
0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 164 total points
ID: 10903149
Client side only for both a missing page and server down you can use XMLHTTP to allow you page to stay in control:

<script language='JavaScript'>
<!--
function testIt(url)
{
   if (document.all)
   {
      // IE version
      try {
      var xml = new ActiveXObject("Microsoft.XMLHTTP");
      xml.Open( "GET", url, false );
      xml.Send()
       }
      catch (e) {
      var xml = new ActiveXObject("MSXML2.XMLHTTP.4.0");
      xml.Open( "GET", url, false );
      xml.Send()
      }
   }
   else
   {
      // Mozilla/Netscrap 6+ version
            var xml=new XMLHttpRequest();
            xml.open("GET",url,false);
            xml.send(null);
   }
}/*
Now you can test the status. You can find the HTTP status codes here:
http://www.w3.org/Protocols/HTTP/HTRESP.html
*/
if (http.status == 404 || http.status == 500) {
// Do something because the page cannot be accessed
   location.href="notfound.htm";
}
if (http.status == 200) {
// Do something because the page does exist
   location.href="http://domain.site.com/page.htm"
// of course you could also used what has already been retrieved
// with document.documenElement.innerHTML=xml.responseText
}
}
//-->
</script>

Cd&
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question