Rewrite Performance Question

Boris Dolgov boris at dolgov.name
Mon Jul 19 14:20:49 MSD 2010


On Mon, Jul 19, 2010 at 1:59 PM, Juergen Gotteswinter <jg at internetx.de> wrote:
> Hi,
>
> come some take a look at these rewrite rules if they are ok regarding
> performance?
>
>
>        if ($host = 'forum.de' ) {
>            rewrite ^/(.*)$ http://www.forum.de:81/$1 permanent;
>        }
>
>        if ($host ~* ^(www\.)??forum\.(at|ch|com|eu|info|net|org)) {
>            rewrite ^(.*)$ http://www.forum.de:81 last;
>        break;
>        }
>   }
Hi!
Never use if ($host ...
Different servers with different server_names must be used instead:
server
{
    server_name forum.de;
    location / { rewrite ^ http://www.forum.de:81/$request_uri? premanent; }
}
server
{
    server_name ~^(www\.)??forum\.(at|ch|com|eu|info|net|org);
    location / { rewrite ^ http://www.forum.de:81/$request_uri? premanent; }
}


-- 
Boris Dolgov.



More information about the nginx mailing list