a "clean" url function.
Date: 01/09/09
(PHP Community) Keywords: cms, google
Hello!
I've created a CMS which deals primarily in links.
When someone adds a link, I also compare it to other links to see if there's a match.
Here lies my query:
How do I make it so every link that gets passed is "cleaned"?
By clean, I mean something like: http://google.co.uk/ (i.e. URL normalisation-ish)
I'm just looking to ensure that all URLs submitted follow the same "pattern," so if someone omits a www and one doesn't, then I don't get any duplicate records.
I've tried, at the moment, a str_replace on www. and converting the link to lowercase, but I'm not sure it's entirely "functionable." If someone has www in the page name, for example...
Much help would be appreciated, thank you!
Source: http://community.livejournal.com/php/652115.html