Rewrite Performance Question

Juergen Gotteswinter jg at internetx.de
Mon Jul 19 15:26:46 MSD 2010


Ok :) thanks to both of you

Juergen

On 07/19/2010 01:10 PM, Igor Sysoev wrote:
> On Mon, Jul 19, 2010 at 02:20:49PM +0400, Boris Dolgov wrote:
> 
>> 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; }
>> }
> 
> Also, in the second server it's better to use usual names instead of regex:
> 
>      server_name   forum.at www.forum.at
>                    forum.ch www.forum.ch
>                    ...
>                    ;
> 
> 



More information about the nginx mailing list