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

  • Home
  • SEARCH
  • 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 7834895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:23:16+00:00 2026-06-02T13:23:16+00:00

I am having a need of getting http response code for page urls from

  • 0

I am having a need of getting http response code for page urls from sitemap.xml file. When i get the response code by my cron process it returns 403 (Known as access forbidden : though i can access the passed url from browser).

But if I run the same code from my localhost, it returns the correct http response code (i.e 200).

Why is the difference in returning different http response code from local host and from server ?? How to resolve the problem ?

The code for extracting the http response code is as below.

function check_response_code() {
    $pageurl='http://www.certona.com/online-merchandising/';
    $trimurl = '';
    $start = '';
    $end = '';
    $total = '';

    $start = microtime(true);
    $response_code = '';
    if (!stristr($pageurl, "http://"))
    {
        if (!stristr($pageurl, "https://"))
        {
            $trimurl = "http://" . $pageurl;
        } else
        {
            $trimurl = $pageurl;
        }
    } else
    {
        $trimurl = $pageurl;
    }
    $curl = curl_init();
    //don't fetch the actual page, you only want headers

    curl_setopt($curl, CURLOPT_URL, $trimurl);
    curl_setopt($curl, CURLOPT_NOBODY, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FILETIME, true);

    $result = curl_exec($curl);

    $timestamp = curl_getinfo($curl, CURLINFO_FILETIME);
    $response_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    $mime_type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
    $end = microtime(true);
    $total = round($end - $start, 5);

    if ($timestamp != -1)
    { //otherwise unknown
        $arr=array(date("Y-m-d H:i:s", $timestamp), $response_code, $total, $mime_type); //etc
    } else
    {
        $arr=array("", $response_code, $total, $mime_type);
    }
    echo "<pre>";
    print_r($arr);
    echo "</pre>";
}

Thank you..

  • 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-02T13:23:18+00:00Added an answer on June 2, 2026 at 1:23 pm

    Am not sure but your code seems to work fine

    Try

    check_response_code();
    
    function check_response_code() {
        $pageurl='http://www.certona.com/online-merchandising/';
        $curl = curl_init($pageurl);
        curl_setopt($curl, CURLOPT_NOBODY, true);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_FILETIME, true);
    
        $result = curl_exec($curl);
        $info = curl_getinfo($curl);
        $info['filetime'] = date("Y-m-d H:i:s", $info['filetime']);
        echo "<pre>";
        print_r($info);
        echo "</pre>";
    }
    

    Output

    Array
    (
        [url] => http://www.certona.com/online-merchandising/
        [content_type] => text/html; charset=utf-8
        [http_code] => 200
        [header_size] => 488
        [request_size] => 76
        [filetime] => 2012-04-24 15:11:28
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 1.342
        [namelookup_time] => 0
        [connect_time] => 0.25
        [pretransfer_time] => 0.25
        [size_upload] => 0
        [size_download] => 0
        [speed_download] => 0
        [speed_upload] => 0
        [download_content_length] => 0
        [upload_content_length] => 0
        [starttransfer_time] => 1.342
        [redirect_time] => 0
        [certinfo] => Array
            (
            )
    
        [redirect_url] => 
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having a hard time getting this to work, all I need to do
We need to protect a class from having static methods for security purposes. We
I am having a bit of difficulty getting mod_rewrite to do what I need
I’m having a problem getting the data from my database which I created to
I'm having a software who is doing a http GET request and then I
I am having trouble getting some data from a JSON object which I have
I am having trouble getting server variables remotely in VB .Net I need to
I'm having issues getting my table to work. I really need to figure out
I am having trouble getting a success: function(){} working - the ajax code I
I am having trouble getting my code to run in a callback using 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.