繁体   English   中英

将htaccess apache重写为nginx

[英]rewrite htaccess apache to nginx

如何转换此重写代码:

RewriteCond $1 !^(index\.php|static|favicon\.ico|robots\.txt|sitemap.xml|google(.+)\.html)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

这来自Stikked脚本https://github.com/claudehohl/Stikked/blob/master/htdocs/.htaccess

我尝试以nginx格式重现它,但出现错误,表明变量$1是未知的

if ($1 !~ "^(index.php|static|favicon.ico|robots.txt|sitemap.xml|google(.+).html)"){
    set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
    rewrite ^/(.*)$ /index.php?/$1 last;
}

尝试这个:

if ($request_uri !~ "^(index.php|static|favicon.ico|robots.txt|sitemap.xml|google(.+).html)"){
    rewrite ^/(.*)$ /index.php?/$1 last;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM