我使用在线转换器将以下 Apache mod_rewrite 转换为 NginX 重写:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1 [R=301,L]
输出如下所示:
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite /. /index.php last;
}
if ($http_host ~* "^www.(.*)$"){
set $rule_1 1$rule_1;
set $bref_1 $1;
}
if ($rule_1 = "1"){
rewrite ^/(.*)$ http://$bref_1 permanent;
}
虽然转换在添加到 vhosts 文件时有效,但有人向我指出转换很差,而且http://docs.ngx.cc/en/latest/topics/depth/ifisevil.html
有人可以帮我“正确”转换吗?
谢谢你。