Mod 重写所有不是来自我的域和子域的流量

发布于 2024-09-02 06:18:29 字数 412 浏览 2 评论 0原文

此时,我服务器上的每个站点都位于域“mydomain.com”或“subdomain.mydomain.com”上,我根据用于访问该站点的子域进行各种重写。

我现在想做的是将任何不是来自我的域或子域的请求发送到脚本进行处理......听起来很简单,但我无法让它工作......

这就是我所拥有的:

RewriteEngine on
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^(.*)\.mydomain\.com
RewriteRule (.*) /_testing/htaccess/off.php?$1

它正确地让我的域或子域上的任何流量都会通过,但在重写时会出现 500 内部服务器错误。我错过了一些明显的东西吗?

At this time every site on my server is on the domain "mydomain.com" or "subdomain.mydomain.com", I do various re-writes depending on the subdomain used to access the site.

What I want to do now, is send any request NOT from my domain or subdomains to a script for handling...... sounds simple, but I can't get it working..

This is what I have:

RewriteEngine on
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^(.*)\.mydomain\.com
RewriteRule (.*) /_testing/htaccess/off.php?$1

It correctly lets any traffic on my domain or subdomain through, but gives a 500 internal server error on the re-write. Am I missing something obvious?

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

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

发布评论

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

评论(2

少女情怀诗 2024-09-09 06:18:29

试试这个规则:

RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$
RewriteCond $1 !=/_testing/htaccess/off.php
RewriteRule (.*) /_testing/htaccess/off.php?$1

Try this rule:

RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$
RewriteCond $1 !=/_testing/htaccess/off.php
RewriteRule (.*) /_testing/htaccess/off.php?$1
香橙ぽ 2024-09-09 06:18:29

事实证明,htaccess 规则无限期地重定向。这是因为我的处理程序脚本位于 /htaccess/ 目录本身内。

我已将处理程序文件移动到另一个位置,现在可以使用:

RewriteEngine on
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$
RewriteRule (.*) /_testing/get.php?http_host=%{HTTP_HOST}

It turned out that the htaccess rule was redirecting indefinitely. This was because my handler script was inside the /htaccess/ directory itsself.

I've moved the handler file to another location and this now works:

RewriteEngine on
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$
RewriteRule (.*) /_testing/get.php?http_host=%{HTTP_HOST}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文