html - <a href="www.example.com">example</a> redirects to mysite.com/www.example.com? -


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

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo