AXiSS Posted February 11, 2007 Share Posted February 11, 2007 I want to use eregi() to check for a correct url. I want to allow people to enter subdomains, domains, and directories, but no specific files, like any of these would be valid: test.url sub.test.url test.url/sub/ sub.test.url/sub/ The http:// will be added after validation. What would be the best way to validate that with eregi()? Quote Link to comment https://forums.phpfreaks.com/topic/38024-best-eregi-url-validator/ Share on other sites More sharing options...
Jessica Posted February 11, 2007 Share Posted February 11, 2007 http://www.phpfreaks.com/forums/index.php/topic,96280.0.html Quote Link to comment https://forums.phpfreaks.com/topic/38024-best-eregi-url-validator/#findComment-182003 Share on other sites More sharing options...
AXiSS Posted February 11, 2007 Author Share Posted February 11, 2007 Still no URL validation. Quote Link to comment https://forums.phpfreaks.com/topic/38024-best-eregi-url-validator/#findComment-182133 Share on other sites More sharing options...
The Bat Posted February 11, 2007 Share Posted February 11, 2007 Is this what you want? - if (eregi("^www\.[a-z0-9_\-]+\.[a-z0-9_\-\.]+$", $url)) { // Code when accepted... } else { // Code when denied... } Quote Link to comment https://forums.phpfreaks.com/topic/38024-best-eregi-url-validator/#findComment-182158 Share on other sites More sharing options...
AXiSS Posted February 11, 2007 Author Share Posted February 11, 2007 No, that doesn't look right. I think this is what I need: if(eregi("^[a-z0-9\-\.]+[a-z0-9\-/]+$", $url)){ ... But I'm not sure if that is the best way... Quote Link to comment https://forums.phpfreaks.com/topic/38024-best-eregi-url-validator/#findComment-182242 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.