0
我正在嘗試更改我的新Nginx服務器上的配置,使其與我當前的Apache設置相匹配。 目前我使用這個htaccess文件:Nginx重寫相當於Apache重寫
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
我已經找到了一個轉換器,可以「翻譯」到這個Nginx的等價物。我曾嘗試以下:
location/{
if (!-e $request_filename){
rewrite ^/(.*) /index.php?url=$1 break;
}
try_files $uri $uri/ =404;
}
但是,當我嘗試設置這樣的http://domain.tld/something我的PHP文件的URL查詢得到返回和下載,是不應該發生的。
我期待發生的事情是當進入像http://domain.tld/something的URL它被當作http://domain.tld/index.php?url=something
誰能告訴我什麼,我做錯了什麼?
嗨,喬恩。謝謝回覆。我得到了腳本的下載部分。我原來是其他代碼中的錯誤。但是我的重寫問題仍然存在 – madsobel 2014-09-23 20:23:20
@madsobel NGINX重寫很好,你清除了瀏覽器的緩存嗎? – 2014-09-23 20:28:23