Effective method to check whether a URL exists or not using PHP

196 Views Asked by At

I'm trying to validate Google indexed URLs for a given domain in real time to return the valid pages count. I tried using PHP get_headers() and curl method. But even for 50 URLs both methods are taking more than 1 minute.

Is there any other easy method I can use to check whether a URL exists or not? As I have to show the result in real time it should take few seconds only.

Any help would be appreciated. Thanks

1

There are 1 best solutions below

1
On

You can use the get_headers function

$headers = @get_headers($url);
$valid = $headers && $headers[0] != 'HTTP/1.1 404 Not Found';