我对nginx定位块有麻烦。
location /myApp/api/account/tutorialPage {
alias /data/www/;
index tutorial.html;
}
如果有严格的匹配-所有都是好的,可以访问我的tutorial.html。
但是我希望每个包含/tutorialPage的链接都会导致tutorial.html。
所以我做了下一个位置:
location ~ /tutorialPage {
alias /data/www/;
index tutorial.html;
}
它必须类似于“如果链接包含/tutorialPage而不是转到tutorial.html”。但是我有403个错误。
错误 10148#0:*65346目录索引"/data/www“被禁止,客户端: 194.183.181.44,服务器:,请求:"GET /myApp/api/account/tutorialPage/ HTTP/1.1",主机:"my.domain.com",引用者:"https://my.domain.com/”
我已经检查过数据/www dir有chmod 755 (例如,可以被enyone读取)。
工作地点示例
location ~ /tutorialPage\z {
rewrite ^/.* /tutorial redirect;
}
location /tutorial {
alias /data/www;
index tutorial.html;
}
发布于 2016-02-03 15:18:13
您需要在内部重写URI:
location ~ /tutorialPage {
rewrite ^ /tutorial.html last;
}
index
指令确定遇到目录时的默认操作,这里不是这种情况。
https://serverfault.com/questions/753742
复制相似问题