rewrite or return for simple redirection

Maxim Dounin mdounin at mdounin.ru
Fri Nov 21 19:33:46 UTC 2014


Hello!

On Fri, Nov 21, 2014 at 11:21:40AM -0800, neubyr wrote:

> I am trying to understand which option would result in more efficient HTTP
> redirection. I am trying to redirect ^/address page to ^/contact page.
> 
> Option 1:
> rewrite ^/address /contact permanent;
> 
> Option 2:
> location ~ ^/address {
>   return 301 $scheme://$host/contact
> }
> 
> Which option should be preferred? Both options involve regex and I am not
> sure which one will be faster. Are there any other better options?

    location = /address {
        return 301 /contact;
    }

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list