I just learned from a colleague that omitting the "http | https" part of a URL in a link will make that URL use whatever scheme the page it's on uses.
So for example, if my page is accessed at http://www.example.com and I have a link (notice the '//' at the front):
<a href="//www.google.com">Google</a>
That link will go to http://www.google.com.
But if I access the page at https://www.example.com with the same link, it will go to https://www.google.com
I wanted to look online for more information about this, but I'm having trouble thinking of a good search phrase. If I search for "URLs without HTTP" the pages returned are about urls with this form: "www.example.com", which is not what I'm looking for.
Would you call that a schemeless URL? A protocol-less URL?
Does this work in all browsers? I tested it in FF and IE 8 and it worked in both. Is this part of a standard, or should I test more browsers?
You can link to "example.com", example.com, example.com or just //example.com. The latter stating that you should use your current client's protocol (usually a browser http/https, but could be an email client, etc.) and is extremely useful when you consider a site having both http and https protocols running.
HTTP, or Hypertext Transfer Protocol, is a common sight in web browsers everywhere. HTTP helps web browsers to understand the data that is being delivered to them by servers. Without HTTP, we wouldn't expect such communication to exist – we'd not be able to browse the web.
You don't need to include the protocol (the browser uses HTTP by default) or the port (which is only required when the targeted Web server is using some unusual port), but all the other parts of the URL are necessary.
So yes you need to put http, https, or www, just to let browser know that you redirecting user somewhere outside of this site(server), or it will try to find path you specified on current server. It is because each link is just a path to some document and protocol explicitly says that it is other server.
Protocol relative URL
You may receive unusual security warnings in some browsers.
See also, Wikipedia Protocol-relative URLs for a brief definition.
At one time, it was recommended; but going forward, it should be avoided.
See also the Stack Overflow question Why use protocol-relative URLs at all?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With