0

I have ann Array of urls

$arr = Array(
       'http://magento2.com/url-exist',
       'http://magento2.com/url-does-not-exist',
       'http://magento2.com/url-does-not-exist',
       'http://magento2.com/url-exist');

I've tried curl, get_headers they all failed

output is wrong:

<a href="http://magento2.com/url-exist" >Link-1</a>
<a href="http://magento2.com/url-does-not-exist" >Link-2</a>
<a href="http://magento2.com/url-does-not-exist" >Link-3</a>
<a href="http://magento2.com/url-exist" >Link-4</a>

It should return only url 1 and 4 200 status code e.g:

<a href="http://magento2.com/url-exist" >Link-1</a>
<a href="http://magento2.com/url-exist" >Link-4</a>

However it's returning all 200 but 2 and 3 should return 404

Anyone have any idea why ?

Thanks in advance!

4

1 Answer 1

0
  1. php bin/magento indexer:reindex, php bin/magento cache:clean

  2. <?php
    $arr = Array(
        "link 1" => 'http://magento2.com/url-exist',
        "link 2" => 'http://magento2.com/url-does-not-exist',
        "link 3" => 'http://magento2.com/url-does-not-exist',
        "link 4" => 'http://magento2.com/url-exist'
    );
    
    foreach($arr as $key=>$url)
        \Zend_Debug::dump($key.' = '.array_values(get_headers($url))[0]);
    ?>
    

    Result :

    string(24) "link 1 = HTTP/1.0 200 OK"
    
    string(31) "link 2 = HTTP/1.1 404 Not Found"
    
    string(31) "link 3 = HTTP/1.1 404 Not Found"
    
    string(24) "link 4 = HTTP/1.0 200 OK"
    
1
  • Thanks but that's exactly what I am doing. however in my local server works but In the remote server it doesn't so I've contact server support. thanks. Oct 29, 2018 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.