Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cons and Pros of Protocol-Less-Urls "//example.org" vs "http://www.example.org"

Tags:

http

url

As I am uncertain yet which version to settle with http://www.exampe.org OR http://example.org (eventually I have to choose but for now I cannot choose). Meanwhile I want to promote my site online: post a link here or there. Now, I was wondering whether it would be a good idea to have a protocolless hyperlinks e.g. //example.org as URL!

That way the urls on the net wont be picky and allow some space to be good for both with or without www. Its simpler smaller and it seems to work fine in FireFox!

Questions
1.What are the pros and cons of using protocollless Urls?
2.Why aren't other folks using them?

Thanks! Very curious to your insights. Much appreciated.

like image 337
Sam Avatar asked Apr 22 '11 12:04

Sam


2 Answers

The main reason to use these URLs are in a site that uses both HTTP and HTTPS (with the same page). The idea being that links to static content on the page use // instead of http://, inheriting the protocol from the page. This allows the client to add the correct protocol (so secure pages don't have "insecure items" on them) and removes the need to code two versions of the page or have special "tricks" to change the protocol when the page is generated.

For any URL outside of this, not adding a protocol will mean that users may directly come to your site with an HTTPS request, adding unnecessary load to your site. I suggest explicitly specifying the protocol in such cases.


As for the issue of using www or not - it depends on what else you will have on the server and if you expect subdomains (if you add a blog, will it have a blog.example.com URL or an example.com/blog URL). If you do expect subdomains, use www to signify main site, if you don't you can omit it.

like image 80
Oded Avatar answered Nov 15 '22 06:11

Oded


With regard to using www.example.com or example.com for a website, there are good reasons to use both. Some argue that the only real thing people will be using your domain name for is to go to your webserver, thus www. is considered redundant by those of that opinion.

I personally prefer www.example.com as one can create a CNAME record for that. This is useful if you ever want/need to put a website behind a CDN, as root domain names cannot be CNAMEs.

In either case, you would most likely want the one you are not using to give redirects to whichever you are using so regardless of where a user hits they will get to the server.

As for why people don't use //example.com or //www.example.com my guess would be:

  • The thought of a link without a protocol is scary and seems odd...
  • Most markup parsers probably don't recognize it, either.
like image 37
SymKat Avatar answered Nov 15 '22 08:11

SymKat