以下是 Apache 的写法: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^test.domain.com [NC] RewriteCond %{REQUEST_URI} !^/test/ RewriteRule ^(.*)$ test/$1?Rewrite [L,QSA] </IfModule> 如果换成 Nginx 的写法是怎么写? if ($http_host ~* "^test.domain.com"){ set $rule_0 1$rule_0; } if ($uri !~ "^/test/"){ set $rule_0 2$rule_0; } if ($rule_0 = "21"){ rewrite ^/(.*)$ /test/$1?Rewrite last; } 不知道对不对 yxmss 发表于 2022-7-11 00:09 不知道对不对 不对,不过谢谢你 # domain.com server { server_name domain.com; location / { } } # test.domain.com server { server_name test.domain.com; rewrite ^ $scheme://domain.com/test$uri permanent; } 复制代码