【发布时间】:2015-08-09 18:18:32
【问题描述】:
我正在尝试在 nginx 服务器上设置 CakePHP。 Following their blog tutorial 在为 nginx 设置 URL 重写时,我在我的站点可用/默认文件中结束了这个:
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 时,它会显示默认的“欢迎到 nginx”页面。如果我尝试访问 localhost/StudentRecords/webroot,我会收到 414 错误,并最终得到如下 URL:
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,以及为什么我的网址会这样成倍增加。
【问题讨论】:
-
唯一用于该请求的服务器块是第一个。为什么这是一个重定向循环应该很明显,因为它所做的唯一一件事就是重定向到自身,将 path 更改为以 'localhost' 为前缀
-
谢谢。我想我对重写行的观察不够仔细。
标签: cakephp nginx url-rewriting