Insights

How to check if requested url exits or not

$requestedUrl = “http://www.example.com/abc.php”;
$tags = get_headers($requestedUrl);
if(preg_match(“/Not Found/i”,$tags[0]) || preg_match(“/Service Unavailable/i”,$tags[0]))
{
echo “Requested Url does not exists”;
}
else
{
echo “Requested Url exists”;
}

Turn insight into action

Need help with php or a related project?

If this article sparked an idea, question, or project direction, I can help you turn it into a practical next step.

Start a conversationChat on WhatsApp

Related reading

Articles connected to this topic

apache

401 Response when PHP-FPM Enabled on WordPress CMS

We recently migrated our website to another hosting service running FPM/FastCGI . We noticed under the website CMS -> tools -> Site Health Status , that all our REST API calls were failing authentication. It appeared to turn the request into an request from an Anonymous user even though we passed Basic Authentication h

Jan 2, 2025

Read article

Most recent

Latest posts from the blog

View all articles →