Regular expression for URL validation

Some times we may need to validate the URL from back-end or front-end.

I used following codes and works good for me. You can check it once if you need.

So for PHP

    function is_valid_url($url) {
        return preg_match('/^((ht|f)tp(s?)(:\/\/))?([a-z0-9-]+[.]{1})+[a-z0-9-]+(:[0-9]*)?(\/{1}[a-zA-Z0-9\-\.\?\,\:\!\'\/\\\+&%\$#_=]+)*\/?$/i', $url);

And for JS

    function is_valid_url(url) {
        var urlregex = new RegExp(/^((ht|f)tp(s?)(:\/\/))?([a-z0-9-]+[.]{1})+[a-z0-9-]+(:[0-9]*)?(\/{1}[a-zA-Z0-9\-\.\?\,\:\!\'\/\\\+&%\$#_=]+)*\/?$/i);
        return urlregex.test(url);

This will allow following pattern of URL!landingpage