2

JSFiddle

I have a link in my site:

<a href="www.bff.org.uk">BFI</a>

This may appear on a page with the URL:

mysite.com/articles/60

Clicking the link will go to

mysite.com/articles/60/www.bff.org.uk

I know adding http to the anchor resolves this, but why does www not go to the site? Is there a way to fix it so that www links do go to the site?

panthro
  • 22,779
  • 66
  • 183
  • 324
  • yes, add http:// to the start. or to keep the same protocol add "//", e.g. "//www.bff.org.uk" – Rhumborl Mar 02 '16 at 11:53
  • `Basically, any text in the href without a protocol is assumed to be a relative path if there is no / or protocol.` - http://stackoverflow.com/questions/8997790/why-does-an-anchor-tags-href-values-need-http-preprended-to-the-url and http://stackoverflow.com/questions/8951423/html-links-without-http-protocol. Because there are lots of different protocols, so one must be defined. – Nick R Mar 02 '16 at 12:01

2 Answers2

3

...but why does www not go to the site?

Why would "www" imply that the URL's scheme is http by default? What if you had a folder named www.bff.org.uk set up in your site? Also why couldn't "www" here have a scheme of https, ftp or file? What about tel, app or even skype or itunes?

Is there a way to fix it so that www links do go to the site?

Not without adding in the http:// part or introducing some peculiar JavaScript to detect and convert this for you.

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
0

You need to use http or https protocols

<a href="http://www.bff.org.uk/">BFI</a>

you should read here html - links without http protocol

Community
  • 1
  • 1
mr. pc_coder
  • 16,412
  • 3
  • 32
  • 54