Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Check URL Existence Using PHP

Saturday, Jan 21, 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.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH