我有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,server:,request:“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; }
您需要在内部重写URI:
location ~ /tutorialPage { rewrite ^ /tutorial.html last; }
index指令确定遇到目录时的默认操作,这里不是这种情况。