There are two sites, one with content and the other with landing.

You need to instantly redirect the user from content.domain.com to domain.com

ubuntu server with apache and nginx

How can I make an instant redirect, but with the condition that access to content.domain.com/folder and content.domain.com/dashboard will be possible without a redirect?

I tried to make a redirect using the nginx config, entered into the server {} section

server_name www.content.domain.com; rewrite ^ http://domain.com permanent; 

and after that I lost the ability to click on the link content.domain.com/dashboard, etc.

  • and in what case should the redirection work? - aleksandr barakin
  • @ alexander-barakin when the user goes to the content.domain.com or www.content.domain.com it needs to be transferred to domain.com - Danylo
  • i.e., if url is / . and what difficulties did you encounter during implementation? please specify them directly in the question by clicking edit below the text of the question. - aleksandr barakin

1 answer 1

you need to redirect when you request / , i.e. when accessing the site root, but for any other url - do not redirect.

then write in the appropriate directive:

 rewrite ^/$ http://domain.com permanent;