[英]How to redirect NGINX
I'm trying to redirect from https://support.example.com.br/ for https://support.example.com.br/?SSO=1
我如何通過 nginx 做到這一點? 我的代碼是這樣的:
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;
}
請不要就同一問題提出第二、第三等問題。 使用評論系統來澄清您對特定答案的問題。 要在請求中已指定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.