Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Links start with two slashes [duplicate]

More and more, began to notice that the links in the source code on Web sites begin with two slashes. For example:

<a href="//example.com/1.png">Image</a> 

Why do it?

like image 352
Kirill Firsov Avatar asked Sep 01 '11 16:09

Kirill Firsov


People also ask

What does 2 forward slashes mean in a URL?

A double slash in the URL path is valid and will respond in the browser, but is typically unwelcome, as this could cause duplicate content issues if the CMS delivers the same content on two URLs (i.e. single slash and double slash).

How do you fix a double slash in URL?

If the double slash in the page's permalink is generated by your CMS, you might need to address your developer for help. If the URL with a double slash is indexed in Google or has incoming external links, you can set the proper 301 redirects to the corrected URL.

Why are there two slashes after?

I'm asking what does mean of first two slashes? file:// or http:// ? @LetDoit - those are the characters chosen as the designated separator when drafting the rfc for uri format.

What is double slash in HTML?

The "two forward slashes" are a common shorthand for "request the referenced resource using whatever protocol is being used to load the current page".


1 Answers

It's a protocol-relative URL (typically HTTP or HTTPS). So if I'm on http://example.org and I link (or include an image, script, etc.) to //example.com/1.png, it goes to http://example.com/1.png. If I'm on https://example.org, it goes to https://example.com/1.png.

This lets you easily avoid mixed content security errors.

like image 107
Matthew Flaschen Avatar answered Sep 24 '22 10:09

Matthew Flaschen