Nginx redirect all requests from subdirectory to another subdirectory root

后端 未结 3 1620
名媛妹妹
名媛妹妹 2020-12-31 06:16

I\'m quite new to Nginx so please bear with me.

I\'m trying to redirect all requests from one subdirectory (store) to the root of another subdirectory (trade). See

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 07:04

    ok try something like this

    location ^~ /store(.*) {
      return 301 $scheme://$http_host/trade$1$is_args$query_string;
    }
    

    Trying to avoid hardcoded stuff as much as possible and using return because it's prefered over permanent rewrites

提交回复
热议问题