2

How can you use regular expression to do this:

preprod.*.company.com > root to /home/preprod_folder
*.company.com > root to /home/prod_folder

I know that to match *.company.com I will create:

server_name *.company.com

But what about for a regular expression that match before *.company.com, this rule preprod.allsubdomains.company.com

preprod.*.company.com is not working, and that's normal.

Could you help me please?

Thanks.

Xanarus
  • 763
  • 1
  • 6
  • 18

1 Answers1

1

You say "redirect", but it looks like your intent is to set the root directory instead. Perhaps this is what you are looking for:

    server_name ~^preprod\.(?<subdomain>\w+).company.com;
    root /home/prepod_folder;
Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49
  • Yes this is working, but If I add the other rule *.company.com (so both rules), *.company.com match before your rule.. – Xanarus Jan 21 '16 at 20:19
  • I added this rule also for *.company.com ( server_name ~^(?!preprod)\.(?\w+).mycompany.com; )) and this is working, thanks! – Xanarus Jan 21 '16 at 20:24