server {
listen 8000;
server_name local.server;
# root /Users/username/code/project/register;
# Works if root defined here and location / is deleted
location /register { # root seems to be set to location / always
root /Users/username/code/project/register;
try_files $uri $uri/ /index.html?/$request_uri;
}
location / {
root /Users/username/code/web/public;
try_files $uri $uri/ /index.html?/$request_uri;
}
}
local.server:8000 / register总是尝试从位置/
的根目录服务器文件我想要
位置/ - > root code / web / public
位置/注册 - >根代码/项目/注册
这可能吗?
答案 0 :(得分:2)
我怀疑您root
的值不正确。您指向/Users/username/code/project/register/register
。
尝试:
location /register {
root /Users/username/code/project;
...
}
此外,/register
下的默认操作是转到另一个根下的/index.html
。您的意思是指定/register/index.html
吗?
例如:
location /register {
root /Users/username/code/project;
try_files $uri $uri/ /register/index.html?/$request_uri;
}