用户可以请求“Referer”吗?只在服务器端修改?

发布于 2024-08-05 04:51:47 字数 222 浏览 3 评论 0原文

我有一个网站服务器,它执行这样的工作:

服务器接收来自用户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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

划一舟意中人 2024-08-12 04:51:48

不,重定向只是告诉客户端使用不同的 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.).

撕心裂肺的伤痛 2024-08-12 04:51:48

据我所知,浏览器会自动设置引荐来源网址,除非用户禁用该行为。所以:不,你不能在服务器端更改它。

因为网站B(我的客户)想知道我给他带来了多少访问量;我不想修改我的客户端软件,想知道是否有其他软件可以得到这个:)

您可以在 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.

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 :)

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.

情魔剑神 2024-08-12 04:51:48

据我所知,只能通过客户端(例如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文