Page 1 of 1

How to check url exist or can be opened or not, if not then

Posted: Thu Feb 27, 2014 9:54 pm
by weixin268
How to check url exist or can be opened or not, if not then open alternative link.

e.g.

<? php
if exist(<a href="http://www.server1.com/link.php")Link</a>)
else (<a href="http://www.server2.com/link.php")Link</a>)
?>

Re: How to check url exist or can be opened or not, if not t

Posted: Fri Feb 28, 2014 12:49 am
by requinix
More information would be great. What are these servers? Do you control them? Where are these URLs coming from?

Re: How to check url exist or can be opened or not, if not t

Posted: Fri Feb 28, 2014 1:32 am
by weixin268
As sometimes, the server1 will down or cannot be connected, then user can open server2 link, all the pages are same.

http://www.server1.com/link.php cannot open or reach
try http://www.server2.com/link.php

But user only need to click one link

<a href=".........">Link</a>

Re: How to check url exist or can be opened or not, if not t

Posted: Fri Feb 28, 2014 2:32 am
by requinix
Okay, progress. How about the rest of my questions? And why might these servers be down? Is it possible for a server to be up but the link to still not work?

By the way, I'm not asking because I want to be difficult. I'm asking because the answers will help you get the best solution for your problem.

Re: How to check url exist or can be opened or not, if not t

Posted: Fri Feb 28, 2014 3:23 am
by weixin268
Okay, here is the reasons why. Actually the first link want the user(s) to connect is for security issues. If user(s) at office network, click on Link will open the first link for them (i.e. http://192.168.0.x/link.php). When the user(s) are out of office, when they click on the Link then will open the external link for them (http://www.domain.com/link.php). Actually they are pointing to the same server, same page.