mod_rewrite 将所有流量从特定域重定向到特定页面

发布于 2024-10-03 06:15:07 字数 528 浏览 0 评论 0原文

我希望所有带有 REFERER“bad-domain.com”的流量都转到名为 Hole 的特定页面。它似乎在 .htaccess 中根本不起作用,所以我将它放在服务器配置中。它是一个 wp,所有其余的重写内容都在 .htaccess 中——这是非常典型的 wp 重写。

我遇到了各种各样的问题,一旦我遇到了重定向循环,一旦我得到了 400。当前的配置会公开整个站点的根目录结构,如果引荐来源网址是坏域,我们不能这样做,所以我暂时对其进行了评论。

我想我明白一切,我知道我非常接近答案,但我不知道如何让它完全按照我想要的方式做,而不是我不想要的。

如果 .htaccess 符合这些条件,它似乎会忽略它。它不是先做 serverconfig 的东西,然后再做 htaccess 的东西吗?

这是服务器配置中的三行

RewriteCond %{HTTP_REFERER} .*xxxxxx.com.* [NC]
RewriteCond %{REQUEST_URI} !(/)$
RewriteRule ^.*$ /hole/  

I want all traffic with REFERER "bad-domain.com" to go to a specific page named hole. It doesn't seem to work at all in .htaccess so I put it in the server config. It is a wp and all the rest of the rewrite stuff is in .htaccess -- it is pretty typical wp rewrites.

I have had various problems, once I got a redirect loop, and once I got a 400. The current configuration exposes the entire site's root directory structure if the referer is bad-domain we can't have that so I momentarily commented it.

I think I understand everything and I know I'm very close to the answer but I don't know how to make it do exactly what I want and nothing that I don't want.

It seems like it is ignoring the .htaccess stuff if it matches these conditions. doesn't it do serverconfig stuff first and THEN do htaccess stuff?

This is the three lines in the server config

RewriteCond %{HTTP_REFERER} .*xxxxxx.com.* [NC]
RewriteCond %{REQUEST_URI} !(/)$
RewriteRule ^.*$ /hole/  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文