html - <a href="www.example.com">example</a> redirects to mysite.com/www.example.com? -
this question has answer here:
example:
<a href="www.example.com"> click here go www.example.com!</a>
and
<a href="http://www.example.com"> click here go www.example.com!</a>
the first 1 redirects following url: http://www.currentsite.com/www.example.com
while second 1 works fine.
here's code i'm using: (ruby on rails)
<%=h link_to @user.details.website, @user.details.website, :class => 'link'%>
the solution have checking http://
, add if it's not there.
why, yes. uris not starting /
or ...://
relative uris , resolved against current uri. browser has no idea mean "www.example.com" domain name, because it's valid path name , looks relative uri.
you have 3 choices:
- start protocol (
http://example.com
) link different protocols and/or domains - start
/
link different absolute path within current domain - link relative paths current path within current domain