由于网站需要使用伪静态才能使用,所以写了一条规则
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?/$1 last;
}
try_files $uri $uri/ =404;
}
但是又想使用 https 访问网站,所以又写了一条 rewrite 规则,然后访问网站的时候就报重定向过多
server {
listen 80;
listen [::]:80;
server_name example.com;
rewrite ^/(.*) https://example.com/$1 permanent;
}
只要取消下面这个 rewrite 规则,访问就是正常的,请问各位大佬,代码应该如何优化能达到既能伪静态又能成功重定向 http 到 https ?