location /shopgl { try_files $uri $uri/ /shopgl/index.html; index index.html index.htm; }
时间: 2024-04-04 18:35:49 浏览: 10
这是一个Nginx的配置,表示当访问`/shopgl`这个路径时,会先尝试访问对应的文件,如果文件不存在,则会重定向到`/shopgl/index.html`,最后再尝试访问对应的文件。如果还是不存在,则会返回404错误页面。`index index.html index.htm;`表示在访问路径时,如果没有指定具体的文件名,则会默认访问`index.html`或`index.htm`文件。
相关问题
location / { try_files $uri $uri/ /index.html; }是什么意思?
这是一个 Nginx 的配置文件,其中 location / 表示匹配所有请求,try_files $uri $uri/ /index.html; 表示尝试匹配请求的文件,如果找不到则返回 index.html 页面。
try_files $uri $uri/ /index.php?$query_string; 下面能加rewrite配置吗
可以加上rewrite配置,如下所示:
```
location / {
try_files $uri $uri/ /index.php?$query_string;
rewrite ^/example/(.*)$ /index.php?example=$1 last;
}
```
这个配置会将所有以/example/开头的请求重写为/index.php?example=xxx的形式,然后交给后端处理。