How to redirect domain aliases via Nginx?

  • 0
    The domain has multiple aliases.

    I need to redirect for example to
    And Redirect to

    if ($http_host = '') {
        rewrite ^(.*) https:/ permanent;
    if ($http_host = '') {
        rewrite ^(.*) permanent;

    Is there another option to get by with one block?
    Nginx Emma Ramos, Aug 6, 2019

  • 1 Answers
  • 0
    Why go for one block if your processing is different? Other things being equal, it is better to make separate server blocks than crutches with ifs.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!