CakePhp& Nginx子页面未显示

时间:2014-09-17 07:43:19

标签: php cakephp nginx

我最近在端口8085上的nginx上托管了cakephp app。

我重新启动nginx并正确加载索引页面。 但每当我点击同一网站(另一页)的某些链接时,网上就没有任何内容。

请告诉我我的nginx设置有什么问题。

这是我的nginx conf。

server { 
    server_name  example.com;
    root   /var/www/html/cakephp/app/webroot;
    access_log  /var/log/nginx/cakeapp.access.log;
    error_log   /var/log/nginx/cakeapp.error.log;

    listen       8085;
    rewrite_log on;

    # rewrite rules for cakephp
    location / {
        index  index.php index.html;

        # If the file exists as a static file serve it 
        # directly without running all
        # the other rewite tests on it
        if (-f $request_filename) { 
            break; 
        }
        if (!-f $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
            break;
        }
    }

    location ~* \favicon.ico$ {
        expires 6m;
    }
    location ~ ^/img/ { 
        expires 7d; 
    } 

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       # include /etc/nginx/fastcgi_params;
    include /etc/nginx/fastcgi.conf;
        fastcgi_param SERVER_NAME $host;
    }

    location ~ /\.ht {
        deny  all;
    }
}

1 个答案:

答案 0 :(得分:0)

它的路由与cake php有点不同,试试这个

root DIR/app/webroot/;
    location / {
        index index.php index.html;
        rewrite ^/$ /index.php?url=/;
        if (!-e $request_filename) {
            rewrite ^(/.*)$ /index.php?url=$1 last;
        }
    }

我不会尝试这段代码,但你可以。