2017-09-15 116 views
0

這是我的第一個問題。NGINX中的URI重定向

我在CodeIgniter中開發了一個Web應用程序。它在Apache上運行得很好。但是,當我上傳到我的服務器,它不再工作。服務器使用NGINX。

我使用.htaccess從URL中刪除index.php。

這裏是我的.htaccess文件:

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

如果我不這樣做,並保持的index.php比它工作正常。 我該怎麼辦?

回答

0

nginx不支持.htaccess。將設置寫入/etc/nginx/nginx.conf

Nginx不支持Apache的重寫引擎的語法。

阿帕奇

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

爲Nginx的相同重寫(自動變換)

location/{ 
    if (!-e $request_filename){ 
    rewrite ^(.*)$ /index.php/$1 break; 
    } 
} 
+0

謝謝,我必須在服務器端做,而不是在本地系統。如何在服務器上做到這一點。我沒有找到「/etc/nginx/nginx.conf」。 – chiku

+0

也許你可以找到一個類似'/ etc/nginx/sites-enabled/yourSite(或默認)的文件' – spinsch

+0

我發現/ etc /但是沒有任何東西像Nginx或其他。裏面有mydomain_name和webdav等。 – chiku