1

Using NGINX, I want to redirect domain.com/support/* to support.domain.com/*.

I have the initial domain.com/support to support.domain.com redirect working, but I'm not sure how to make it dynamic:

  server {
    server_name support.domain.com;
    rewrite ^(.*)$ $scheme://www.domain.com/support$1 permanent;

    location ^~ /support/ {
        rewrite ^/support/(.*) $scheme://support.domain.com/$1 permanent;
    }
  }

If I go to domain.com/support/page, it doesn't redirect to support.domain.com/page. I'm not sure how to implement that part.

10
  • That looks reasonable at first glance. What is the problem you are having with it? Jul 10, 2018 at 15:20
  • @MichaelHampton If I go to domain.com/support/page, it doesn't redirect to support.domain.com/page. I'm not sure how to implement that part Jul 10, 2018 at 15:21
  • So what actually does happen? Jul 10, 2018 at 15:24
  • @MichaelHampton No redirect and domain.com/support/page just loads, which is an old page structure. The current redirect only explicitly affects domain.com/support Jul 10, 2018 at 15:25
  • 1
    @MichaelHampton I see. So, if I move the location rule into the domain.com server block, would this work with subdirectories beyond just /support, i.e. /support/page? EDIT: It worked in the correct server block! Thanks again Jul 10, 2018 at 15:43

0

You must log in to answer this question.

Browse other questions tagged .