Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does 301 redirect always preserve referrer?

I want to know whether 301 redirect always preserve referrer.

I make a page called "gotoorig_https.html" which contains a hyperlink to a page "orig_https.asp".
"orig_https.asp" will 301 redirect to "dest.html" which shows the document.referrer.

In this case,

http page(gotoorig_https.html) -> orig_https.asp(301 redirect)-> https page (dest.html) <--the referrer preserves  
https page(gotoorig_https.html) -> orig_https.asp(301 redirect)-> https page (dest.html) <--the referrer preserves  

I also make a page called "gotoorig_http.html" which contains a hyperlink to a page "orig_http.asp". "orig_http.asp" will 301 redirect to "dest.html" which shows the document.referrer.

In this case,

http page(gotoorig_http.html) -> orig_http.asp(301 redirect)-> http page (dest.html) <--the referrer preserves  
https page(gotoorig_http.html) -> orig_http.asp(301 redirect)-> http page (dest.html) <--the referrer DOES NOT preserve.

Why does the last case happen?

like image 849
Billy Avatar asked Sep 09 '09 08:09

Billy


People also ask

Are 301 redirects permanent?

A 301 redirect is a permanent redirect that passes full link equity (ranking power) to the redirected page. 301 refers to the HTTP status code for this type of redirect. In most instances, the 301 redirect is the best method for implementing redirects on a website.

What is the benefit of 301 redirect?

A 301 signals a permanent redirect from one URL to another, meaning all users that request an old URL will be automatically sent to a new URL. A 301 redirect passes all ranking power from the old URL to the new URL, and is most commonly used when a page has been permanently moved or removed from a website.

Would it be necessary to 301 redirect every page on a site?

301 redirects should be used when a page is no longer relevant, useful or has been removed. They are also really valuable for site rebuilds, where URLs are tidied up into the newer, cleaner pages. It is very important to redirect any old URLs that won't be staying the same on a rebuild of your website.


2 Answers

RFC doesn't specify any referrer-specific behavior in status 301 definition, nor 301-specific behavior in Referer header definition. Thus, I have to say that although this referrer-preserving behavior is logical, it is not defined in RFC and thus you can never be sure.

like image 139
Michał Górny Avatar answered Oct 29 '22 03:10

Michał Górny


When going between HTTP and HTTPS the HTTP spec says that a referer header should NOT be sent (see 15.1.3 in RFC2616). The spec doesn't say what should happen between HTTPS pages however.

Interestingly firefox defaults to ignoring the spec in this case, but can be made to conform by setting the network.http.sendSecureXSiteReferrer configuration setting.

like image 14
blowdart Avatar answered Oct 29 '22 04:10

blowdart