Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:27:04+00:00 2026-06-01T19:27:04+00:00

I’m building a little web app that will ping an array of domains and

  • 0

I’m building a little web app that will ping an array of domains and return their status, letting me monitor if they’re up or down, pointing to the right servers, etc. (live example that may or may not be working)

I started out using exec("ping -n 3 -w 3 {$_POST['host']}", $output, $status); and am now using exec("traceroute -w 1 {$_POST['host']}", $output, $status); and grabbing the last $output and matching the IP there.

This works for the most part except I’m noticing it’s not following 301 redirects, etc.

For example a traceroute on myrayhawk.com yields something like:

 1  192.168.1.1 (192.168.1.1)  0.495 ms  0.683 ms  0.911 ms
 2  10.71.96.1 (10.71.96.1)  32.220 ms  55.987 ms  57.109 ms
 3  ip68-4-12-93.oc.oc.cox.net (68.4.12.93)  58.231 ms  59.353 ms  60.424 ms
 4  68.4.15.242 (68.4.15.242)  72.339 ms  73.451 ms  74.641 ms
 5  ip68-4-11-16.oc.oc.cox.net (68.4.11.16)  76.265 ms  77.383 ms  79.591 ms
 6  ip68-4-11-94.oc.oc.cox.net (68.4.11.94)  143.201 ms  18.749 ms  41.717 ms
 7  langbprj01-ae1.rd.la.cox.net (68.1.1.13)  42.843 ms  43.971 ms  68.194 ms
 8  reserved.metro.la.ipv4.godaddy.com (206.223.123.32)  45.094 ms  70.501 ms  69.329 ms
 9  ip-97-74-253-94.ip.secureserver.net (97.74.253.94)  71.622 ms  72.754 ms  74.844 ms
10  ip-97-74-253-94.ip.secureserver.net (97.74.253.94)  108.322 ms  112.058 ms  109.446 ms

11  ip-97-74-253-98.ip.secureserver.net (97.74.253.98)  110.589 ms  37.376 ms  38.861 ms
12  ip-97-74-254-134.ip.secureserver.net (97.74.254.134)  68.868 ms  70.791 ms  72.282 ms
13  ip-184-168-86-185.ip.secureserver.net (184.168.86.185)  82.400 ms  76.183 ms  78.540 ms

But doing the same on rayhawk.com since I know there’s a 301 redirect in there:

 1  192.168.1.1 (192.168.1.1)  0.738 ms  0.868 ms  1.174 ms
 2  10.71.96.1 (10.71.96.1)  95.723 ms  119.914 ms  122.994 ms
 3  ip68-4-12-89.oc.oc.cox.net (68.4.12.89)  123.558 ms  124.115 ms  124.679 ms
 4  68.4.15.240 (68.4.15.240)  127.319 ms  127.933 ms  128.523 ms
 5  ip68-4-11-16.oc.oc.cox.net (68.4.11.16)  126.672 ms  132.373 ms  131.802 ms
 6  ip68-4-11-94.oc.oc.cox.net (68.4.11.94)  130.986 ms  65.913 ms  64.542 ms
 7  langbprj01-ae1.rd.la.cox.net (68.1.1.13)  89.395 ms  88.751 ms  88.113 ms
 8  reserved.metro.la.ipv4.godaddy.com (206.223.123.32)  97.840 ms  89.999 ms  90.593 ms
 9  po36.trma0202-01.bbn.mgmt.phx3.gdg (216.69.188.33)  98.454 ms  99.034 ms  115.921 ms
10  po36.trma0202-01.bbn.mgmt.phx3.gdg (216.69.188.33)  114.698 ms  114.032 ms  115.263 ms
11  * * *
12  * * *
13  * * *
14  * * *
15  * * *

I’ve tried using wget --spider hostname.com but wget doesn’t like to work nicely in php exec() calls.

When doing a wget in plain SSH I get:

Resolving rayhawk.com... 72.167.131.159
Connecting to rayhawk.com|72.167.131.159|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.rayhawk.com/ [following]
Spider mode enabled. Check if remote file exists.
--2012-04-12 11:37:42--  http://www.rayhawk.com/
Resolving www.rayhawk.com... 72.167.131.159
Connecting to www.rayhawk.com|72.167.131.159|:80... connected.
HTTP request sent, awaiting response... 200 OK

And could then parse out the stuff I wanted.

How can I resolve the final location of a host and retrieve it’s HTTP status code in PHP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:27:06+00:00Added an answer on June 1, 2026 at 7:27 pm

    I’ve written a blog post about how to get the trail of HTTP redirects that can happen, it comes with code examples:

    • HEAD first with PHP Streams + Updated codepad viper example

    Example output for http://example.com/:

    Status code (after all redirects): 200
    Number of responses: 2 (1 Redirect(s))
    * http://example.com/ -- 302 --> http://www.iana.org/domains/example/
    

    You find a more in depth discussion of the code in the answer to a related question HTTP response code after redirect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.