2013-02-02 50 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;