我有一个网站,我正在以https模式渲染,我已经在default.conf中编写了重写规则,如下所示:
listen 80;
server_name hostname.com;
rewrite ^ https://$server_name$request_uri? permanent;但是,我需要从重写中排除index.html或/。如何编写规则将index.html或/排除在重写之外?
发布于 2014-07-04 14:20:37
我看不出这样做的原因,但这里有一个示例,它从重写中排除了/和/index.html。此外,我还将rewrite更改为更有效的return指令。
listen 80;
server_name example.com;
root /path/to/root/dir;
# exclude / from rewrite
location = / {
index index.html;
}
# exclude /index.html from rewrite
location = /index.html {
}
location / {
return 301 https://$host$request_uri;
}https://stackoverflow.com/questions/24566898
复制相似问题