【发布时间】:2019-05-16 05:55:51
【问题描述】:
当用户访问 www.website.com 时,我希望像用户访问 www.website.com/frontend/ 一样提供内容。但是,我想屏蔽 url 的 /frontend/ 部分,以便用户看不到它。这个可以吗?
我的重写规则会是什么样子?
已解决:
location = / {
rewrite ^/$ /frontend/ last;
}
我的问题是
location = / {} #Matches the path project.example.com only (mind there is a =)
location / {} #Matches every path (mind: there is no =)
【问题讨论】:
-
所有网址
/some/path都应该转到/frontend/some/path? -
它应该提供来自我的 django 应用程序的内容,就好像用户去了 /frontend/some/path 一样,正确。但我不希望用户在 url 中看到 /frontend/,只是从 /frontend/ app 接收到内容
-
为什么不将前端脚本包含在主页中?为什么不使用
location = / { ... root /frontend}?
标签: python django nginx url-rewriting