Home > Mobile >  How to redirect NGINX
How to redirect NGINX

Time:12-08

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? 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;
    }
}

CodePudding user response:

server {
  ...

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

CodePudding user response:

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:

server {
    ... # global server block directives

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

    ... # your locations goes here
}
  • Related