location /bo/ {
root /var/www/mysite/web/bo/;
try_files $uri $uri/ /index.php?$args;
index /bo/index.php; # it's not work
}
location / {
root /var/www/mysite/web/;
try_files $uri $uri/ /index.php?$args;
index index.php; # it's work
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
}
当我请求mysite.com/
时,我会收到index.php
的回复,但是当我请求mysite.com/bo/
时,我发现错误,可能index
derictive不起作用?或者第二次derictive更新第一index
derictive。我有一个问题。首先:如果请求存在location /
,如何进入/bo/
?
我解决了这个问题
location /bo/ {
try_files $uri $uri/bo/ /bo/index.php?$args;
}
location / {
root /var/www/mysite/web/;
try_files $uri $uri/ /index.php?$args;
index index.php; # it's work
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
}
答案 0 :(得分:0)
您已指定root
目录,因此index
必须是相对路径。在您的情况下index index.php
。
location /bo/ {
root /var/www/mysite/web/bo/;
try_files $uri $uri/ /index.php?$args;
index index.php;
}