rxohbg
Last Updated: February 25, 2016
·
638
· alexanderbrevig
Feb007acc38e70d57f7b4c205f7e8b26

Drop protocol in URIs

So this protip is very simple.

DO: //somesite.com/somepath/somefile.js or relative /somepath/somefile.js

DON'T: http://somesite.com/somepath/somefile.js

If you use //somesite.com/somepath/somefile.js for all your references, the browser will fill in the protocol for you. So if you're visiting the page with https, the ref will become https://somesite.com/somepath/somefile.js.

I recently had to make on of my sites be HTTPs compliant. Luckily it was as easy as setting up an SSL and change the default protocol for my sites.
Because of this trick, I had no insecure resources and no warnings on my site.

Excellent!

Say Thanks
Respond

3 Responses
Add your response

16109
77facb9235772ebd506e15c680fe8e73

Should there be a colon here? https//somesite.com/somepath/somefile.js.

over 1 year ago ·
16114
Feb007acc38e70d57f7b4c205f7e8b26

Of course

over 1 year ago ·
23414
Caf0114fa7087c4fda4d54afb28e95ca

I was hoping you would answer "NO because you shouldn't fill in the protocol" ;) awesome tip though

over 1 year ago ·