简体   繁体   English

如何重定向 NGINX

[英]How to redirect NGINX

I'm trying to redirect from https://support.example.com.br/ for https://support.example.com.br/?SSO=1 I'm trying to redirect from https://support.example.com.br/ for https://support.example.com.br/?SSO=1

how do i do this through nginx?我如何通过 nginx 做到这一点? my code is like this:我的代码是这样的:

server {
    listen 8080;
    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;

    location / {
        rewrite ^/$  /?SSO=1$1 redirect;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SERVER_NAME $host;    
    }
    location ~ /\.ht {
        deny  all;
    }
    location ~ php-errors\.log$ {
        deny all;
    }
}
server {
  ...

  rewrite ^/$ /?SSO=1 permanent;
}

Please, do not ask second, third and so on questions about the same problem.请不要就同一问题提出第二、第三等问题。 Use the comments system to clarify your problems with the particular answer.使用评论系统来澄清您对特定答案的问题。 To prevent a redirect when the SSO query argument already specified in request, try this:要在请求中已指定SSO查询参数时防止重定向,请尝试以下操作:

server {
    ... # global server block directives

    if ($arg_SSO = '') {
        rewrite ^/$ /?SSO=1 permanent;
    }

    ... # your locations goes here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM