0
我想爲nginx翻譯下面的apache htaccess重寫規則。翻譯nginx的htaccess重寫規則
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.+) /index.php
任何想法如何做到這一點?
我想爲nginx翻譯下面的apache htaccess重寫規則。翻譯nginx的htaccess重寫規則
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.+) /index.php
任何想法如何做到這一點?
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;
}