Nginx重写414-URI太大

时间:2015-08-09 18:18:32

标签: cakephp nginx url-rewriting

我正在尝试在nginx服务器上设置CakePHP。关于为nginx设置URL重写的Following their blog tutorial,我在我的sites-available / default文件中得到了这个结果:

server {
    listen  80;
    server_name localhost;
    rewrite ^(.*) localhost$1 permanent;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name localhost;

    root /usr/share/nginx/html/StudentRecords/webroot;
    index index.php index.html index.htm;

    error_page 404 /404.html;

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

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

/ usr / share / nginx / html / StudentRecords /是我的CakePHP应用程序的首选目录。

当我转到URL localhost时,它会显示默认的“Welcom to nginx”页面。如果我尝试访问localhost / StudentRecords / webroot,我会收到414错误,最终会得到这样的网址:

http://localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/localhost/StudentRecords/webroot/

我无法理解为什么服务器根目录不指向StudentRecords / webroot,以及为什么我的网址会像这样倍增。

2 个答案:

答案 0 :(得分:1)

删除第一个服务器块

答案 1 :(得分:1)

看起来rewrite ^(.*) localhost$1 permanent;行(和第一个代码块)是不必要的。删除第一个块以及清除浏览器缓存已解决了这两个问题。