2009-10-13 69 views
2

除了通过我的域名进行网络访问外,我的ISP允许通过以下格式访问我的网站:user.hostname.com,其中user是我的登录名,hostname是我的ISP。我已经写了重写规则,自动将user.hostname.com重新映射到www.mydomain.com,这很好。然而,事实证明,我查看我的网站上的统计数据,我的ISP要求我访问user.hostname.com/stats/index.html。随着我的重写规则,这将改为www.mydomain.com/stats/index.html,我无法访问统计页面。允许网址避开.htaccess中的mod_rewrite规则

有什么办法可以让user.hostname.com/stats通过不变,同时仍然重写所有其他user.hostname.com请求?

谢谢。

回答

4

如果使用Apache 2.2+试试这个:

RewriteRule ^/stats(|/.*)$ - [last] 
# After that the other rewrites... 

对于Apache 2.2 mod_rewrite的似乎不支持 ' - ' 的替代模式(DASH)。在这种情况下,请使用以下规则:

RewriteRule ^/stats(|/.*)$ /stats$1 [last] 
+0

谢谢。刚刚尝试了您的建议,但它给出了一个服务器配置错误的错误。 有没有其他想法? – James 2009-10-13 16:56:25

+0

适用于我,使用Apache 2.2.11。你使用的是什么Apache版本?如果你有其他的RewriteRules工作,你可以在这里粘贴一些示例conf? – 2009-10-14 13:28:44

+0

只有ISP发布的信息是Debian Linux 4.0 Apache。 rewritecond%{http_host}^user \ .hostname \ .com [nc] rewriterule ^(。*)$ http://www.mydomain.org/$1 [r = 301,nc] rewritecond%{http_host}^www \ .hostname \ .com [nc] rewriterule ^(。*)$ http://www.mydomain.org/$1 [r = 301,nc] rewritecond%{http_host}^mydomain \ .org [nc] ] rewriterule ^(。*)$ http://www.mydomain.org/$1 [r = 301,nc] rewritecond%{http_host}^mydomain \ .com [nc] rewriterule ^(。*)$ http ://www.mydomain.org/$1 [r = 301,nc] rewritecond%{http_host}^www.mydomain \ .com [nc] rewriterule ^(。*)$ http://www.mydomain.org/$ 1 [r = 301,nc] – James 2009-10-14 16:54:18