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()? 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 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. 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... } 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... Link to comment https://forums.phpfreaks.com/topic/38024-best-eregi-url-validator/#findComment-182242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.