用户可以请求“Referer”吗?只在服务器端修改?
我有一个网站服务器,它执行这样的工作:
服务器接收来自用户A的请求(请求引用为空),然后将用户A重定向(在服务器端)访问网站B;
有什么办法可以将用户A的请求引用者修改为我的域名,然后站点B可以从用户A的请求中获取我的域名吗?
提前致谢!
因为网站B(我的客户)想知道我给他带来了多少访问量;我不想修改我的客户端软件,想知道是否有其他软件可以得到这个:)
I have a web site server which do such work like this:
The server receives request from user A(request referer is blank) and then redirect(at server side) user A to visiting web site B;
Is there any way I could modify user A's request referer to my domain name, then site B can get my domain name from user A's request?
Thanks in advance!
Because the web site B (my customer) want to know how many visits I have brought to him; I don't want to modify my client software and want to know if there's another can get this :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,重定向只是告诉客户端使用不同的 URL 来完成请求。但对新 URL 的实际请求是由客户端而不是服务器完成的。仅当客户端以非 HTTP 方式(链接点击、表单提交、“元重定向”等)访问 URL 时,才会设置 Referer 标头字段。
No, a redirect is just telling the client to use a different URL to complete the request. But the actual request to the new URL is done by the client, not the server. And the Referer header field is only set when the client followed an URL on a non-HTTP way (link click, form submission, “meta redirect”, etc.).
据我所知,浏览器会自动设置引荐来源网址,除非用户禁用该行为。所以:不,你不能在服务器端更改它。
您可以在 URL 中附加一个唯一标识符,以便您的客户可以跟踪谁来自您的网站:
http://www.yourcustomer.com/page.html?ref=bluesea007
实际上, Google Analytics 利用了这一原则。
As far as I know, the browser automatically sets the referrer unless the user disabled that behaviour. So: no, you can't change it server-side.
You could append a unique identifier to the URL so that your customer can track who is coming from your site:
http://www.yourcustomer.com/page.html?ref=bluesea007
Actually, Google Analytics makes use of this principle.
据我所知,只能通过客户端(例如 JavaScript)重定向。这种事情你只需要尝试一下就可以看到。
Only via a client-side (e.g. JavaScript) redirect as far as I know. The kind of thing you just have to try it and see.