2013-02-02 48 views
0

有使用zend框架的網頁。網頁實際上使用重寫。我用Google搜索的解決方案如何設置Zend Framework的勝利nginx的..他們說這是沒有必要的默認重寫的.htaccess轉換爲nginx的一個..nginx日誌中的奇怪錯誤

反正這裏的.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

RewriteRule ^robots\.txt$ robots.txt 

這裏的nginx的配置網頁:

server { 
    listen 80; ## listen for ipv4; this line is default and implied 
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 

    root /var/www/vhosts/domain.lt/httpdocs; 
    index index.php; 

    # Make site accessible from http://localhost/ 
    server_name domain.lt; 
    server_name www.domain.lt; 

    location/{ 
     if (-f $request_filename) { 
       root /var/www/vhosts/domain.lt/httpdocs; 
      } 
    } 

    location ~* ^/(favicon.ico|robots.txt)$ { 
      access_log off; 
      log_not_found off; 
    } 

    error_page 404 = /index.php; 

    # redirect server error pages to the static page /50x.html 
    # 
    #error_page 500 502 503 504 /50x.html; 
    #location = /50x.html { 
    # root /usr/share/nginx/www; 
    #} 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     #fastcgi_param SCRIPT_FILENAME /var/www/vhosts/domain.lt/httpdocs/index.php; 
     include fastcgi_params; 
    } 

    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    location ~ /\.ht { 
     deny all; 
    } 

    location ~* \.(css|js|jpeg|jpg|gif|png|ico|xml)$ { 
     access_log off; 
     expires 30d; 
    } 
} 

最後錯誤本身:

2013/02/03 01:52:13 [error] 12293#0: *29 open() "/var/www/vhosts/domain.lt/httpdocs/daiktai/kategorija/slaugos-ir-higienos-priemones/page/147" failed (2: No such file or directory), client: 66.249.75.237, server: domain.lt, request: "GET /daiktai/kategorija/slaugos-ir-higienos-priemones/page/147 HTTP/1.1", host: "www.domain.lt" 

,你可以看到nginx認爲每個重寫都是一個文件入口,這當然不存在。我該如何解決這個問題?網頁實際上很​​好,沒有重寫。 我的問題是:如何從error.log中刪除這些錯誤,我需要將該htaccess文件轉換爲nginx重寫?如果是的話,你可以轉換它嗎?我嘗試了一些在線轉換器 - 完全忽略了RewriteCondRewriteRule

回答

0

找到解決方案:

這個整體的一部分是錯誤的

location/{ 
     if (-f $request_filename) { 
       root /var/www/vhosts/domain.lt/httpdocs; 
      } 
    } 

我只是說這server

try_files $uri $uri/ /index.php; 

和這location ~ \.php$

try_files $uri =404; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_param PATH_INFO $fastcgi_script_name;