Regex Url Verification Php

Regex Url Verification Php
I have a form where users enter a url. It needs to be specifically like this:
http://somecustominfo.mysite.com/
http://anotherclient.mysite.com/
http://athirdclient.mysite.com/

I need a function that takes the url entered in the form and checks it:
http://somecustominfo.mysite.com/ -> ok return the url
http://anotherclient.mysite.com/ -> ok
http://athirdclient.mysite.com/ -> ok
http://athirdclient.mysite.com -> http://athirdclient.mysite.com/
athirdclient.mysite.com -> http://athirdclient.mysite.com/
athirdclient.mysite.com/ -> http://athirdclient.mysite.com/
something.wrongsite.net -> error return ”
http://www.mysite.com/ -> error return ”

Leave a Reply

Your email address will not be published. Required fields are marked *