473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I verify if a domain redirect to another?

How can I verify if a domain redirect to another site? for html xml xhtml etc.
Jan 21 '10 #1
7 2275
Atli
5,058 Expert 4TB
Hey.

I suppose you could use the get_headers function to check the HTTP headers the domain returns. If the response gives you a 30x status code, it is redirecting you to another location.

The return data from the function would include these two elements, which you could use to determine if, and where to, it is redirecting you.
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [0] => HTTP/1.1 302 Found
  4.     [3] => Location: http://www.example.com
  5. )
  6.  
Jan 21 '10 #2
There are a lot of problems with get_headers. I need a little script wich can return four values: 0 - if domain is not online, 1 - if is online , 2 - if redirect, and new domain if redirect. I have 1800 domain to check. I need to be sure for all kind of servers.
Jan 27 '10 #3
Atli
5,058 Expert 4TB
Ok, what you have tried so far?
What problems are you facing?

We won't write the script for you, but we are more than happy to help you write it.
Jan 27 '10 #4
kovik
1,044 Expert 1GB
Your server is most likely to know the information that you are looking for. PHP is just an intermediary for programmers to their server. If the headers aren't doing it for you, then look online for the type of server you have and how it handles responses.
Jan 27 '10 #5
Yes, but all domain are websites on different servers in world.
Jan 27 '10 #6
kovik
1,044 Expert 1GB
So? You're gonna need to be more clear about what you are trying to accomplish. If you are using your server to send a request, you WILL receive a response. That's how you know what your user would expect as a response when they are redirected. If you want some way of knowing information AFTER the redirection has occurred, you'd need access to the other server.
Jan 27 '10 #7
Atli
5,058 Expert 4TB
@Adrian4net
That's not really true. A domain just points to an IP address. It doesn't necessarily have to have anything to do with a website.

But anyways, to accomplish what you are trying to do (or at least what I think you are trying to do) you just need to follow a fairly simple process.

Consider this pseudo-code (PHPseudo-code, if you will :P):
Expand|Select|Wrap|Line Numbers
  1. if( HEAD request was successfull ){
  2.     if( Status code is 200 ){
  3.         // Server is online and not redirecting you.
  4.     }
  5.     else if( Status code is 300-399 ){
  6.         $location = Location header
  7.         // Server is online and redirecting you to $location.
  8.     }
  9.     else {
  10.         // Server is online and not redirecting you,
  11.         // but the request was not successful.
  12.     }
  13. else {
  14.     // Server is offline.
  15. }
That could be the skeleton of your script. You just need to fill it in with working code.

You can either do this by using the get_headers function I mentioned earlier, or by sending the request by some other means. (Curl, Sockets, etc...)
Jan 27 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Hoge | last post by:
I'm transitioning a site from domainX.com to domainY.com, and I want to redirect all traffic from the old domain to the new. If I set up domainX.com under IIS to "redirect to a URL" the browser...
0
by: sica | last post by:
Hi! I try to log on a domain and I used the following syntax: Response.Redirect "http://userid:password@myaddress.com" . But login dialog box is still apear. All I want it's to supress...
4
by: Reader | last post by:
I have an application that allows a user to enter a user name, user password, and the domain or machine name. From this information I would like to verify the user account and password is valid. ...
11
by: Vic Spainhower | last post by:
Hello, I just purchased a new domain name and I've set it up as a redirect to a folder on my main site. What is happening is the index.php page checks a session variable to see if the user is...
2
by: Wayne Wengert | last post by:
I want to write a Windows application to go through all the email addresses in an SQL Server table and to report which ones are invalid. From Googling and perusing NGs it is my understanding that...
1
by: Fred Nelson | last post by:
Hi: I have a web app that uses three separate domain names - I am trying to develop a "single sign on" routine so that they can move between the sites without having to sign on each time the...
1
by: Grey | last post by:
I have to write a program to verify email address availability. i have to verify thousand of email address. is there any way to verify the email in ..net instead. the requirement is to verify which...
3
by: Grey | last post by:
I have to write a program to verify email address availability. i have to verify thousand of email address. is there any way to verify the email in ..net instead. the requirement is to verify which...
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, We have two sites hosted on different servers and we have many pages on domain A which has many links(asp programs) to domain B. My question is if domain B server is in trouble, what is...
0
by: =?Utf-8?B?UHJpeWE=?= | last post by:
Hi, How do i redirect a request from one domain to another. For example , i want to redirect all requests that come to www.abc.com to www.def.com. I own the source code for website www.def.com....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.