Mod rewrite mod_重写子域重定向,除非指定了文件夹

Mod rewrite mod_重写子域重定向,除非指定了文件夹,mod-rewrite,Mod Rewrite,如果没有指定特定的文件夹,我将如何进行mod_重写以重定向到不同的子域?例如: 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.exampl

如果没有指定特定的文件夹,我将如何进行mod_重写以重定向到不同的子域?例如:

  • 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]

不确定在什么条件下用于用户目录

您可以添加另一个不包括特定文件夹的重写条件:

RewriteCond %{REQUEST_URI} !^/(~user|/.*)$
ReWriteCond %{HTTP_HOST} test.example.com [NC]
ReWriteRule ^$ http://redirect.example.com [L,R]
您应该删除另一个重写中的“=”