2014-09-05 60 views
-2

我想轉換此.htaccess文件:的.htaccess的RewriteRules到nginx.conf

Options -MultiViews 

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-l 

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 

進入一個nginx.conf文件。到目前爲止,我的nginx.conf文件看起來像這樣:

server { 
    listen 80; 
    server_name _; 
    root /var/www/app; 
    index index.php; 

    location/{ 
    try_files $uri /index.php; 
    } 

    location ~ \.php$ { 
    fastcgi_pass 127.0.0.1:8080; 
    fastcgi_index index.php; 
    include fastcgi_params; 
    } 
} 

我得到一個502壞的網關錯誤。

回答

1

正確的位置,以兼容Apache的重寫:

location/{ 
    try_files $uri /index.php?$args; 
    } 

和錯誤502意味着FPM-PHP(FastCGI的)後端下跌,但這不是nginx的問題:)

+0

仍然不工作!但非常感謝您的幫助! – kampfkuchen 2014-09-05 17:11:00

+1

位置{}代碼不修復502問題,您必須啓動php-fpm服務,但我們將在這裏進入offtopic) – 2014-09-05 17:28:55

+0

我修復了502問題,感謝您的支持。但我的MVC仍然不起作用。它不識別鏈接(索引除外)。 – kampfkuchen 2014-09-05 17:42:44