2015-10-18 139 views
1

如何转换这种重写代码:重写htaccess的阿帕奇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; 
} 

回答

2

试试这个:

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

谢谢!非常 –