Welcome! Log In Create A New Profile

Advanced

Re: rewrite to www EXCEPT for one directory

September 06, 2012 08:16PM
On Friday 07 September 2012 02:51:35 eddy@sdf.org wrote:
> > On Friday 07 September 2012 00:32:48 eddy@sdf.org wrote:
> >
> > And please do not use ugly rewrites instead of simple "return", where
> > it's possible.
>
> maybe it's a stupid question, but: if 'permanent - returns permanent
> redirect with code 301' (http://wiki.nginx.org/HttpRewriteModule), then
> why one should use 'return 301 URL' instat?

Because the "return" directive is a simple construction that doesn't involve
execution of regular expressions, and looks more declarative.

Moreover, you do not need to capture full URI, when you have variables like $uri
and $request_uri. Therefore, something like ^(.*)$ is just a waste of resources.

> or its more about to avoid rewriting rules generaly? if yes, why is this
> so? a few weeks ago, i followed a discussion about to avoid if-rules
> because of performance with large rule sets. but i can't see this argument
> with one rewriting rule, which only takes action at first connect from
> client to server.

This is less about performance, but rather it's more about keeping config clean
and simple.

> it's just a little bit confusing for me 'cause of so many poorly writen
> config examples around the web, and it's the first time i see this way
> with 'return 301 URL' for redirecting example.org to www.example.org.
>

So many examples and tutorials around the web have written by guys who
have little understanding of the subject. And often they just copy-paste
configuration from each other.

But in this particular case, it is worth to bear in mind, that early
versions of nginx doesn't support 'return 30x URL'.

See the official documentation for details: http://nginx.org/r/return

wbr, Valentin V. Bartenev

--
http://nginx.org/en/donation.html
http://nginx.com/support.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite to www EXCEPT for one directory

Ian Evans September 06, 2012 02:24PM

Re: rewrite to www EXCEPT for one directory

VBart September 06, 2012 02:40PM

Re: rewrite to www EXCEPT for one directory

Anonymous User September 06, 2012 04:34PM

Re: rewrite to www EXCEPT for one directory

VBart September 06, 2012 05:36PM

Re: rewrite to www EXCEPT for one directory

Anonymous User September 06, 2012 06:52PM

Re: rewrite to www EXCEPT for one directory

Edho Arief September 06, 2012 08:14PM

Re: rewrite to www EXCEPT for one directory

António P. P. Almeida September 07, 2012 08:22AM

Re: rewrite to www EXCEPT for one directory

VBart September 06, 2012 08:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 195
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready