我一直在尝试做这项工作,但我真的没有选择:)
我正在使用CakePHP 3.0及其建议的配置加上制作/ tools /(其中包含phpmyadmin等)文件夹可访问而无需重定向到index.php
server {
listen 192.168.0.39:80;
server_name 192.168.0.39;
#root www/webroot/;
root www/webroot/;
index index.php;
log_not_found on;
charset utf-8;
access_log logs/access.log main;
location / {
try_files $uri $uri/ /index.php?$args;
}
#the line I am trying to get to work.
location /tools/ {
root www/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root www;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_index index.php;
fastcgi_param PHP_FCGI_MAX_REQUESTS 1000;
#fastcgi_param PHP_FCGI_CHILDREN 100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^.+.(gif|ico|jpg|jpeg|png|flv|swf|pdf|mp3|mp4|xml|txt|js|css)$ {
expires 30d;
add_header Vary Accept-Encoding;
}
if ($request_method !~ ^(GET|HEAD|POST)$ ){ return 405; }
location ~ /(\.ht|\.git|\.svn) {
access_log off;
log_not_found off;
deny all;
}
}
我对此没有任何错误。但如果我将root设置为notexisting
,我会得到:
"C:/server/notexisting/tools/index.php" is not found (3: The system cannot find the path specified)
否则它只显示404。
的access.log
192.168.0.39 - - [17/Jun/2015:17:35:27 +0300] "GET /tools/ HTTP/1.1" 404 191 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36 OPR/30.0.1835.59" "-"
尝试在位置/工具/下使用try_files
,但没有运气。
感谢您的帮助。