Want To Be A Blogger  →  Start A Blog  →  Increase Traffic  →  Make Money Online  →  Recommended Things

Check URL Existence Using PHP

Friday, Dec 15, 2017


In this tutorial we will show you how to check url existence using PHP.There are many times when user submit url for information and other user won't be able to go to that webpage just because the url does not exist and this will also decrease website SEO so in this tutorial we will solve that problem by checking submitted URL if it is exist or not.You may also like Detect URL Using jQuery.

Check URL Existence Using PHP

To Check URL Existence It Takes Only Two Steps:-

  1. Make a HTML file to send URL
  2. Make a PHP file to check URL

Step 1.Make a HTML file to send URL

We make a HTML file and save it with a name send_url.html

<div id="wrapper">
<div id="url_form">
 <form method="post" action="check_url.php">
 Enter URL : <input type="text" name="url">
 <input type="submit" name="submit_url" value="CHECK URL">


In this step we create a form to enter URL for checking by user.

Step 2.Make a PHP file to check URL

We make a PHP file and save it with a name check_url.php

 $url = $_POST['url'];
 $url_headers = @get_headers($url);
  $exist = "URL Exist";
  $exist = "URL Does Not Exist";

In this step we get the URL value submitted by user and then by using PHP get_headers() function we get all the headers of that URL and it return headers array and then we check '200' is present in array's 1st value if yes then the URL is exist and running and if not URL is not running or exist.'200' is URL status '200' means URL is running.You may also like Convert URL Text Into Link Using JavaScript.

Thats all, this is how to check url existence using PHP.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Subscribe Our Newsletter And Get Tutorials And Offers Via Email

About Me

Hello, My Name is Mudit Jain. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of TalkersCode. I started this blog in february 2015 to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers.