除非指定文件夹,否则mod_rewrite子域重定向

时间:2012-11-13 05:39:39

标签: mod-rewrite

如果未指定特定文件夹,我将如何进行mod_rewrite重定向到diffent子域?例如:

  • test.example.com - > redirect.example.com
  • test.example.com/~user/* - 无重定向
  • test.example.com/dir/ - > redirect.example.com

到目前为止我已经

ReWriteCond %{HTTP_HOST} =test.example.com [NC]
ReWriteRule ^ http://redirect.example.com [L,R]

不确定用于用户目录的条件

1 个答案:

答案 0 :(得分:0)

您可以添加另一个排除特定文件夹的ReWriteCond:

RewriteCond %{REQUEST_URI} !^/(~user|/.*)$
ReWriteCond %{HTTP_HOST} test.example.com [NC]
ReWriteRule ^$ http://redirect.example.com [L,R]

你应该删除其他ReWriteCond中的'='。