我有一个文件夹/assets
,其中包含index.hml
,css/*
,js/*
等文件。
这是我要完成的事情:
/
或index.html
服务器index.html
css/main.css
等)我还需要通过查询参数($args
)
这是我的enginx部分配置:
location / {
root /assets;
try_files $uri $uri/index.html$is_args$args =404;
}
使用此设置,我得到以下结果:
domain.com/css/main.css
> 200: domain.com/css/main.css
domain.com/index.html
> 200: domain.com/index.html
domain.com/
> 200: (renders same as domain.com/index.html)
domain.com/index.html?q=x
> 200: domain.com/index.html?q=x
domain.com/?q=x
> 404: Not Found
要使domain.com/?q=x
返回与domain.com/index.html?q=x
而不是不是404相同的响应,我需要做些什么?
答案 0 :(得分:0)
@ richard-smith提出的答案已解决
location / {
root /assets;
index index.html;
try_files $uri $uri/ =404;