I have two websites *.env1.example and *.env2.example, I want to redirect all traffics in env1 to env2, how to do so in Nginx?

I do redirect from one specific domain to another, but now I want to redirect all domains *.env1.example to *.env2.example

  • When you say "from one specific domain" does that mean that you already are redirecting http://env1.example/ to http://env2.example/ just not all the wildcard subdomains? Mar 16 at 9:46
  • Do you already have the wildcard DNS records set up for the two domains and pointing to your server? Mar 16 at 9:46
  • @StephenOstermiller I mean I did redirect from abc.env1.example to abc.env2.example and that works fine but I need to redirect all subdomains. and yes I have DNS records for the two domains (*) and pointing to servers (each one pointing to a different server) Mar 17 at 10:59
  • Did you already configure your virtual hosts in your web server configuration for the wildcard subdomains? It sounds like you intend to have them all pointing to the same document route Mar 17 at 11:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.