Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is URL valid or not [duplicate]

Possible Duplicate:
what is the best way to check if a Url exists in PHP ?`

I'm looking for a function that returns TRUE or FALSE in php, either the URL is valid or not.

isValidURL($url); I think that simple... That would take into count all kind of URL possible.

By valid I want it to refer to an existing page of the web or other kind of files. It just should exist.

like image 712
james Avatar asked Jul 24 '11 13:07

james


People also ask

Can URL be duplicated?

Technically Duplicate Pages Issue means that a particular URL is technically identical to at least one other URL that the search engine has indexed. It can include URLs that are case-sensitive or have the same parameters in a different order.

How do I find the duplicate URL of a website?

To find details of specific URLs with technical duplicates, click on the blue URL Details button from the URL List. The URL Details tab will slide across, and you then need to navigate to Duplicate Content -> URLs, and you'll see all the duplicate URLs underneath.

Is duplicate content good for SEO?

Duplicate content confuses Google and forces the search engine to choose which of the identical pages it should rank in the top results. Regardless of who produced the content, there is a high possibility that the original page will not be the one chosen for the top search results.


2 Answers

<?php

$url = "http://stack*overflow.org";


if(filter_var($url, FILTER_VALIDATE_URL) === FALSE)
{
        echo "Not valid";
}else{
        echo "VALID";
}
?>

this does not check tlds though

like image 63
genesis Avatar answered Oct 11 '22 00:10

genesis


You can check whether URL is valid or not using parse_url function which would return false if URL is not valid and an array otherwise.

function isValidURL($url) { return (bool)parse_url($url); }

pretty easy way, huh? :)

like image 41
Nemoden Avatar answered Oct 11 '22 01:10

Nemoden