我在Github上找到了一個不錯的PHP/MySQL登錄系統。爲了使它正常工作,一個.htaccess文件是必要的。那很棒。事情是,但是,我使用nginx,而不是apache。我怎樣才能將這個重寫規則轉換爲nginx?將三個apache「RewriteCond」規則轉換爲nginx
# Necessary to prevent problems when using a controller named "index" and having a root index.php
# more here: http://stackoverflow.com/q/20918746/1114320
Options -MultiViews
# turn rewriting on
RewriteEngine On
# When using the script within a sub-folder, put this path here, like /mysubfolder/
# If your app is in the root of your web folder, then please delete this line or comment it out
RewriteBase /php-login/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
這是我嘗試過,由apache-to-nginx rules converter網站自動生成:
location /php-login/ {
if (!-e $request_filename){
rewrite ^/php-login/(.+)$ /php-login/index.php?url=$1 break;
}
}
的文件(如的index.php)進行下載,而不是被打開。比起,我在重寫規則的末尾刪除了「break」。有效。但是,我想知道這是否正確,或者如果有另一種更好的方法將此Apache規則轉換爲nginx。
請幫助我解決這個問題https://stackoverflow.com/questions/44346456/apache-auth-rules-converted-for-nginx-server –