I have a comment system that automatically links URLs. I use cakephp, but the solution is just PHP. that's what happens.
if the user enters the full url with http:// or https:// , everything is fine. but if they go to www.scoobydoobydoo.com , it turns into http://cool-domain.com/www.scoobydoobydoo.com . basically, cakephp understands that http | https is an external URL, so it works with http | https otherwise.
My idea was to do something like str on the url and force it to insert http if not. unfortunately, no matter what I do, it only makes the situation worse. I noob :) any help / pointer is appreciated.
thanks
EDIT: posting a fragment of the solution. may not be the best, but thanks to the answer, at least I have something.
<?php $proto_scheme = parse_url($webAddress,PHP_URL_SCHEME); if((!stristr($proto_scheme,'http')) || (!stristr($proto_scheme,'http'))){ $webAddress = 'http://'.$webAddress; } ?>
source share