Nginx:将所有内容重定向到https,除了一个laravel url =太多重定向

时间:2018-01-26 00:11:28

标签: laravel nginx

所以我终于找到了将所有流量从www重定向到非www以及从http重定向到https的方法,但我有一个例外,一个名为tpv的laravel web.php路由,我不想被重定向。如果用户转到https然后就可以了,但如果他们决定使用http,那么没有重定向也没关系

所以我将它集成在下面的代码中,我用不同的想法更改了代码,但最终都得到了“太多的重定向”

我做错了什么?

server {
# Redirect every request to HTTPS...
listen 80;
listen [::]:80;
root /home/forge/example.com/public;
location /tpv {
   try_files $uri $uri/ /index.php?$query_string;
}
server_name .example.com;
return 301 https://$host$request_uri;

# Redirect SSL to primary domain SSL...
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name www.example.com;
return 301 https://example.com$request_uri;

listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
root /home/forge/example.com/public;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

0 个答案:

没有答案
相关问题