Remove http referer

2019-01-04 21:46发布

Is it a way to remove or hide http referer information in request header? i want to remove http referrer information of users who goes to other site from my site using a script possibly in javascript python or django

example:

Host    slogout.espncricinfo.com
User-Agent  Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0    
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8    
Accept-Language en-us,en;q=0.5    
Accept-Encoding gzip, deflate    
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7    
Connection  keep-alive
Referer http://slogout.espncricinfo.com/index.php?page=index&level=login

10条回答
小情绪 Triste *
2楼-- · 2019-01-04 22:21
<meta name="referrer" content="no-referrer"/>

If you put above code on your page all outgoing links (user clicks) will not send referrer information

Documentation

查看更多
狗以群分
3楼-- · 2019-01-04 22:23

I was looking for a solution to this as well, and luckily found this Hide My Referrer site. What impressed me is that it even works for https > https requests.

It will generate a link you can use that will do exactly what your looking for.

查看更多
forever°为你锁心
4楼-- · 2019-01-04 22:25

Your assumption of accessing Referer header via javascript is not possible. Just like the User-Agent header in http, referer etc cannot be accessed by javascript. The values to these headers are fed by the browser. What you can do is some tricky work around's if you require to do so.

查看更多
Juvenile、少年°
5楼-- · 2019-01-04 22:26

There are a variety of mechanisms to do that, depending on what browser version you use. For any browser, if the destination is over HTTP, you can "launder" the origin by redirecting to a HTTPS page which then navigates to the target page.

For IE, you can perform the navigation using JavaScript (e.g. window.open) which will suppress the referer. Or you can use META Refresh, but there's a perf cost to that. For WebKit-based browsers, see the NoReferrer LINK REL option: http://www.webkit.org/blog/907/webkit-nightlies-support-html5-noreferrer-link-relation/

查看更多
做个烂人
6楼-- · 2019-01-04 22:26

I had been searching for a similar solution, blank the referrer, but only to count unique visits from a referring website. The problem I had was that, if someone visited my site from a particular link, the visit counter would go up, but if that person refreshed the page, the visitor counter was still going up.

I used google to visit several resources on this topic and yes it was very very difficult to find the answer until someone pointed me to look at php.net for solution.

I found the solution in using

header('Refresh: 0; url=index.php');

But just the above code is not the solution. Solution lies in its placement. Here is the full code:

$ref=@$_SERVER[HTTP_REFERER];
$domain = parse_url($ref, PHP_URL_HOST);

If ($domain === "google.com") 
    {
        header('Refresh: 0; url=index.php'); //Resets header info to host site so that on page refresh, the hit counter does not
    }                                        // increase but increases only when someone visits from google url again

After the "refresh", header information changes to that of host site, so on page refresh the "if" statement will not validate and the hit counter will not increase.

You can put your hit counter inside the IF block. You can also program different parameters to log blank hits to your website and different parameters to log over all pageloads/pageviews as well.

Hope it helps.....

查看更多
We Are One
7楼-- · 2019-01-04 22:37

There is another method is using history.replace() method to hide the query string such as ,if you want to http://example.com/search?q=100 replace with http://example.com/search,you can do by this way:

history.replace(null,null,'search')

Hope this helps! :D

查看更多
登录 后发表回答