2012-03-05 56 views
0

我試圖使用通常在nginx上運行在Apache上的內部框架。我一直沒有運氣轉換htaccess。Apache到nginx - htaccess不起作用,也沒有嘗試轉換

我試過http://www.anilcetin.com/convert-apache-htaccess-to-nginx/無濟於事。然後我自己做了(做出了不同的規則),這也行不通。這是我目前有:

  index index.php; 

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

      location ~ ^/(assets|robots\.txt|favicon\.ico|license.txt) { 

      } 

      location ~ \.php$ { 
       fastcgi_pass unix:/var/run/php5-fpm.sock; 
       fastcgi_index index.php; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include fastcgi_params; 
      } 

我想轉換htaccess的是:

DirectoryIndex index.php 
RewriteEngine on 
RewriteBase/
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico|license.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 
RewriteCond %{QUERY_STRING} . 
RewriteRule ^$ /? [L] 

有沒有人知道發生了什麼問題,或者我應該怎麼辦呢?

謝謝!

回答

0

在Nginx配置中,你幾乎從不使用if。試試這個吧 -

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

它的其餘部分是不重寫某些文件,所以不需要冗長的正則表達式位置塊。