I have a form where someone enters a URL, I wish to find out if a website that is entered is the main website and not a site that the entered URL is redirected to.
say someone enters [url]http://www.mysite.com
but this site is the old URL and I have a new site where the old site is redirect to being… [url]http://www.mynewsite.com
I wish to get the server response and get the new site that they are redirected to.
How would I do this so I can place an message on the screen that the url they entered is being redirected and to enter the correct url being the site site?
I have been playing around with code for a bit and come up with this…
[code]
var Response = ”;
function loadXMLDoc(url) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
} else {
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”); // code for IE6, IE5
}
//xmlhttp.onreadystatechange=function() {
//if (xmlhttp.readyState==4 && xmlhttp.status==200) {
//Response = xmlhttp.responseText;
Response = xmlhttp.status;
//}
//}
xmlhttp.open(“GET”,url,true);
xmlhttp.send();
}
function update() {
document.getElementById(‘q’).innerHTML=Response;
alert(‘.’ + Response + ‘.’);
}
[code]
<br><br>URL: must include the http://<br><input type=”text” style=”width: 250px;” name=”aUrl” value=”<?php echo ((isset($aUrl) && $aUrl != “”) ? $aUrl : “”); ?>” onKeyUp=”loadXMLDoc(this.value); update();” />
<span id=”q”></span>
All I get is ‘0’ how can I get the server response like 200 or 404 and the like ?