我有一个网站,我以https模式呈现,我在default.conf
中编写了重写规则,如下所示:
listen 80;
server_name hostname.com;
rewrite ^ https://$server_name$request_uri? permanent;
但是,我需要从重写中排除index.html或/
。如何编写规则以排除重写index.html
或/
?
答案 0 :(得分:0)
我认为没有理由这样做,但是这里是从重写中排除/
和/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;
}