开发者

Mod Rewrite all traffic not from my domain and subdomains

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 (.*) /_tes开发者_StackOverflow社区ting/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?


Try this rule:

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


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}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜