Solved

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

Posted on 2004-04-23
5
172 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
5 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 43 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 41 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 41 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Understanding mobile browsers 9 66
Zoom the page when you go in from your phone 3 54
Web forms being filled out by bots 4 36
Button and js nou working 3 8
Find out what you should include to make the best professional email signature for your organization.
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…

831 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