2013-03-11 99 views
0

我想为nginx翻译下面的apache htaccess重写规则。翻译nginx的htaccess重写规则

RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.+) - [PT,L] 
RewriteRule ^(.+) /index.php 

任何想法如何做到这一点?

回答

0

apache重写规则清楚地说明了in the other question,特别是对于非替换的特殊破折号“ - ”规则。这可以被重写为nginx中的try_files指令。

你的问题没有列出空字符串(主页)的规则(只有非空字符串(。+))。所以我假设你在其他地方的主页有一条规则。 nginx中的规则可能是

location =/{ 
    # your nginx rule matching the empty string (for your home page) 
} 

# all other locations try in the order: file => directory => index.php 
location/{ 
    try_files $uri $uri/ /index.php; 
}