Re: rewrite to www EXCEPT for one directory

}
wbr, Valentin V. Bartenev

I suggest to use $scheme like in:

rewrite ^(.*) $scheme://www.example.org/$1 permanent;

to keep the https connection (if a client wants to use it). otherwise
your
server drops the https connection and the client will connect over http.
i.e.: if you want to use /wp-admin only over https with
“define(‘FORCE_SSL_ADMIN’, true);” in /wp-config.php, it will safe you a
lot of annoying behavior…

~ed

On Friday 07 September 2012 00:32:48 [email protected] wrote:
[…]

I suggest to use $scheme like in:

rewrite ^(.*) $scheme://www.example.org/$1 permanent;

to keep the https connection (if a client wants to use it). otherwise your
server drops the https connection and the client will connect over http.
i.e.: if you want to use /wp-admin only over https with
“define(‘FORCE_SSL_ADMIN’, true);” in /wp-config.php, it will safe you a
lot of annoying behavior…

“listen 80;” means that this server section doesn’t handle https
connections.

And please do not use ugly rewrites instead of simple “return”, where
it’s
possible.

wbr, Valentin V. Bartenev


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

On Fri, Sep 7, 2012 at 5:51 AM, [email protected] wrote:

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?

I believe a “return 301 URL” doesn’t do regexp processing compared to
rewrite.

On Friday 07 September 2012 02:51:35 [email protected] wrote:

On Friday 07 September 2012 00:32:48 [email protected] 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

On Friday 07 September 2012 00:32:48 [email protected] wrote:

And please do not use ugly rewrites instead of simple “return”, where it’s
possible.

wbr, Valentin V. Bartenev

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?

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.

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.

~ed

On 7 Set 2012 02h13 CEST, [email protected] wrote:

On Fri, Sep 7, 2012 at 5:51 AM, [email protected] wrote:

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?

I believe a “return 301 URL” doesn’t do regexp processing compared
to rewrite.

You generate the variable/group on the location and then you can use
it on the return statement. Very rarely is there a need to use a
rewrite IMHO. I think it has more to do with the (bad) habits that
mod_rewrite promotes. That’s where we came from.

YMMV,
— appa

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs