繁体   English   中英

根据nginx中的$ uri重定向到其他位置

[英]redirect to different location based on $uri in nginx

如果存在请求参数,我想重定向到其他页面:

http://domain.com  --> index.html

http://domain.com/1 --> return 301 https://$host$request_uri;

当前配置:

server {
    listen 80;
    include /etc/nginx/mime.types;
    location / {
      #return 301 https://$host$request_uri;
      root /usr/share/nginx/html;
   }
}

如何基于uri重定向到位置?

请尝试以下操作:

...
location = / {
       return 301 http://$host/index.html
}

location ~ ^/1 {
       return 301 https://$host/$1
}
...

暂无
暂无

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

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