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 6706205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:29:35+00:00 2026-05-26T07:29:35+00:00

I need to fetch the given website ip address using php, that is ip

  • 0

I need to fetch the given website ip address using php, that is ip address of server in which website is hosted.

For that i’ve used gethostbyname('**example.com*'). It works fine when the site is not redirected. for example if i used this function to get google.com, it gives “74.125.235.20”.

When i tried it for “lappusa.com” it gives “lappusa.com”. Then i tried this in browser it is redirecting to “http://lappusa.lappgroup.com/” . I checked the http status code it shows 200.

But i need to get ip address even if site was redirected, like if lappusa.com is redirected to lappusa.lappgroup.com then i need to get ip for redirected url.

How should i get this? any help greatly appreciated, Thanks!.

  • 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-05-26T07:29:36+00:00Added an answer on May 26, 2026 at 7:29 am

    The problem is not the HTTP redirect (which is above the level gethostbyname operates), but that lappusa.com does not resolve to any IP address and therefore can’t be loaded in any browser. What your browser did was automatically try prepending www..

    You can reproduce that behavior in your code. Also note that multiple IPs (version 4 and 6) can be associated with one domain:

    <?php
    function getAddresses($domain) {
      $records = dns_get_record($domain);
      $res = array();
      foreach ($records as $r) {
        if ($r['host'] != $domain) continue; // glue entry
        if (!isset($r['type'])) continue; // DNSSec
    
        if ($r['type'] == 'A') $res[] = $r['ip'];
        if ($r['type'] == 'AAAA') $res[] = $r['ipv6'];
      }
      return $res;
    }
    
    function getAddresses_www($domain) {
      $res = getAddresses($domain);
      if (count($res) == 0) {
        $res = getAddresses('www.' . $domain);
      }
      return $res;
    }
    
    print_r(getAddresses_www('lappusa.com'));
    /* outputs Array (
      [0] => 66.11.155.215
    ) */
    print_r(getAddresses_www('example.net'));
    /* outputs Array (
      [0] => 192.0.43.10
      [1] => 2001:500:88:200::10
    ) */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to fetch a url with javascript/jquery and not php. i've read that
I'm writing a php script that will fetch data from a given URL and
Here's what I need to fetch: - posts that have comments - number of
Im using vb.net and I need to fetch data from two different tables and
I need to run some code that will fetch some configuration values from the
Iam trying to follow the multithreading example given in: Python urllib2.urlopen() is slow, need
Here's my problem. Given that I am saving data in an array: fetch.on('message', function(msg)
I need to create a PHP class that would send e-mails to all members
Recently I've written recursive PHP function which generates website navigation based on parent-child structure
I just need to fetch some geo data for a given city , i'm

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.