LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-18-2003, 12:35 PM   #1
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
Redirect when web server not responding


Hello,

Yesterday I setup a web server on my home computer, and I'm going to host part of my home page on this server. I say part of since I already have a web page at work which I still want to use, since this has a much better URL. The problem is now that my computer at home is usually switched off when I'm not at home, which will give a lot of errors when someone tries to follow a link from my web page at work, to a page which is on my switched-off home computer.

My question is: is it possible to write something in html/xml/asp/jsp/javascript/whatever, that redirects to my home computer's web page if it is running, but displays another page if it's off? Something like

Code:
if home_server_responds then
   redirect to web page on home server
else
   display another page on the work web page

Thank a lot for any help!

/Stefan
 
Old 11-20-2003, 05:06 AM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Original Poster
Rep: Reputation: 30
Anyone?
 
Old 11-20-2003, 08:59 AM   #3
zekko
Member
 
Registered: Aug 2003
Location: Canada
Distribution: Slackware, debian
Posts: 76

Rep: Reputation: 15
You could try pinging your server (system("ping")), and parse the respond you get. If you get something like 'unable to find the server' redirect them.
 
Old 11-20-2003, 10:40 AM   #4
german
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312

Rep: Reputation: 30
you could write a simple java servlet/JSP for your work computer which would wait for an HTTP request, then once it gets one tries to open that URL (with a very short timeout). If it times out or blows up then send a redirect to the work computer's page, else read the contents of the page and display them. That also has the advantage of making it look like the stuff from your home puter is on the work computer, with the nice URL.

HTH

B.
 
Old 11-20-2003, 11:49 AM   #5
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Original Poster
Rep: Reputation: 30
Thanks guys for your reply! But...my knowledge about programming web pages in anything other than html and css is very bad, so can you give me an example of how to do it, or direct me to some tutorial/how-to where I can find the info myself?

Excuse me for asking to be spoon-fed

Thanks again

Last edited by Bebo; 11-20-2003 at 11:51 AM.
 
Old 07-29-2004, 12:10 PM   #6
f76
LQ Newbie
 
Registered: Jul 2004
Location: Sweden
Distribution: Ubuntu Breezy
Posts: 20

Rep: Reputation: 0
Talking

Try this if u like.. I think u can specify ip:s to..
I know this is a reply to a dead thread but maybe bebbo is still waiting for an answer
Code:
<?php
/*
php adressing styles for linux/internet
http://se.php.net/manual/en/transports.php
*/
error_reporting(0);
$fp = fsockopen("www.test_adress.se", 80, $errno, $errstr, 30);
if (!$fp) {//if not fsockopen ok   
header("Location: http://www.it_didnt_work.se/");
   exit;
} else {
   header("Location: http://www.test_adress.se/");
   exit;
   }
   ?>
 
Old 07-29-2004, 12:22 PM   #7
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Original Poster
Rep: Reputation: 30
Yes, this is indeed a forgotten thread, but thanks a lot for the reply! Unfortunately I have nowhere to test it at the moment, but some day, some day...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(IPTABLES) redirect web site to a file? dmane15 Linux - Newbie 9 08-11-2008 05:53 AM
iptables DNAT redirect to web server problem mitzadej Linux - Networking 6 11-27-2005 10:59 AM
dns server not responding divdude Linux - Networking 10 08-15-2005 02:29 AM
Suse Server 8.0 Stops Responding Henry1 Suse/Novell 0 01-07-2005 12:56 AM
Server not responding on public IP MS3FGX Linux - Networking 4 07-02-2004 04:16 PM


All times are GMT -5. The time now is 11:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration