Protocol-relative URLs are URLs beginning with //. An example is //example.com/file.js. They allow specifying all parts of the URL except the protocol, which is the same as the current page. This mechanism helps avoid mixed content warnings between HTTP and HTTPS.
Questions tagged [protocol-relative]
29 questions
248
votes
7 answers
Can I change all my http:// links to just //?
Dave Ward says,
It’s not exactly light reading, but section 4.2 of RFC 3986 provides for fully qualified URLs that omit protocol (the HTTP or HTTPS) altogether. When a URL’s protocol is omitted, the browser uses the underlying document’s protocol…

a paid nerd
- 30,702
- 30
- 134
- 179
95
votes
4 answers
URI starting with two slashes ... how do they behave?
Lately I saw working code-blocks like this:
And according to RFC 2396 (URI Syntax) and RFC 2616 (HTTP 1.1) these URI starting with two slashes…

pagid
- 13,559
- 11
- 78
- 104
90
votes
3 answers
Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page
I saw the //somepage.com/resource url format. For example:
The point of this is that if the current page (the page defining the img tag) is using http, then the request to the remote site is made via http.…


Bozho
- 588,226
- 146
- 1,060
- 1,140
61
votes
2 answers
Network-Path Reference URI / Scheme relative URLs
Scheme relative URLs (network-path references) are something that I've just found out about - where you don't specify the scheme of a URL and it picks it up from the current context.
For example:
will resolve to…


Jonathon Bolster
- 15,811
- 3
- 43
- 46
30
votes
1 answer
Links start with two slashes
More and more, began to notice that the links in the source code on Web sites begin with two slashes. For example:
Image
Why do it?

Kirill Firsov
- 509
- 1
- 7
- 16
13
votes
3 answers
Preventing secure/insecure errors by using protocol relative URLs for image source
Is anyone aware of whether it is problematic to use protocol relative URLs for an image source to prevent mixed content security warnings.
For example linking an image like:
instead of:


robjmills
- 18,438
- 15
- 77
- 121
11
votes
2 answers
Are protocol-relative URLs relative URLs?
So consider a protocol-relative URL like so;
//www.example.com/file.jpg
The idea I've had in my head for as long as I can remember is that protocol-relative URLs are in fact absolute URLs. They behave exactly like absolute URLs, and never do they…

Emphram Stavanger
- 4,158
- 9
- 35
- 63
10
votes
1 answer
What is the effect of starting a url with "//", and leaving out "http:"
Possible Duplicate:
Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page
I recently noticed that the embed codes for the "like" and "tweet" buttons don't include the http protocol. For example: