[英]How do I config nginx to serve any path to a single specific html file?
I use Vue and prerender a index.html
, and the Vue entry file app.html
.我使用 Vue 并预渲染
index.html
和 Vue 入口文件app.html
。 I need to configure nginx
to serve by the following rules:我需要配置
nginx
以按照以下规则服务:
www.mydomain.com/ => go to /data/www/index.html
www.mydomain.com => go to /data/www/index.html
www.mydomain.com/anything => anything else go to /data/www/app.html
Here is what I wrote in ngnix.conf
but it's not working:这是我在
ngnix.conf
中写的,但它不起作用:
server_name www.mydomain.com;
root /data/www/mydomain/;
location / {
try_files $uri $uri/ $uri/index.html $uri/app.html /app.html ;
}
It does not serve app.html
in any circumstance.它在任何情况下都不适用于
app.html
。 How do I configure to achieve that?我如何配置来实现这一点? Thanks.
谢谢。
Can you try this one?你可以试试这个吗?
location = / {
rewrite . /index.html break;
}
location / {
rewrite . /app.html break;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.