Is REFERER installed if you are redirected to a new web page using location.href =?

If you redirect the user to a new web page using javascript location.href = <url> , what REFERER header is the target web server viewing?

+7
source share
3 answers

he sees the page from which he came, just like clicking on a link.

To check this on any page, redirect to the phpinfo () page or any other page that has an echo header, for example:

 window.location='http://hosting.iptcom.net/phpinfo.php'; 

(page derived from random Google search)

+2
source

With some exceptions, the sent header contains a page with a redirect to it, and not the referrer of the page on which the redirect is performed. This is in contrast to server-side redirects that retain the original referrer.

So, if a visitor moves from A.html to B.html , and B.html triggers a redirect location.href to C.html , the web server will see B.html as a referrer. (If you did a redirect from B.html to C.html on the server, A.html will be the referee for C.html .)

Older versions of Internet Explorer will send an empty header, as it will (as always) redirect from HTTPS to HTTP.

+8
source

Most browsers will pass HTTP_REFFERER with location.href, but IE in some cases does not.

If referrers are really important to you, you can do this:

 function goTo(url) { var a = document.createElement("a"); if(!a.click) { //Only IE has .click so if it doesnt exist use the simple method where the refferer is passed on other browsers. location.href = url; return; } a.setAttribute("href", url); a.style.display = "none"; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(a); a.click(); } 
+2
source

All Articles