Welcome! Log In Create A New Profile

Advanced

Re: Rewrite rules from Apache again

Francis Daly
June 11, 2014 01:06PM
On Wed, Jun 11, 2014 at 06:20:50PM +0200, Luciano Mannucci wrote:
> On Tue, 10 Jun 2014 22:43:05 +0100
> Francis Daly <francis@daoine.org> wrote:

Hi there,

> > The rest of the config?
> :)
> Well, I've posted it in my previous request for help. Beeing
> longish I tried to spare some bandwith... :)

No worries.

It can be useful to have a minimal test case that shows the problem.

> I had it under "location /"
> Moving it to "server" level and adding a "break" seems to make it work!

Very approximately, the order is:

choose the server{}
run the rewrite directives
choose the location{}
run the rewrite directives, looping back as necessary
handle the request

So your non-server-level rewrites will only apply if they are in the
location{} that is chosen.

> > location = /pagina.php {
> > return 200 "I got $uri$is_args$args from $request_uri\n";
> > }
> Many thanks for this elegant way of debugging this kind of
> configuration problems.

You're welcome.

You may also find it useful to enable debug logging for your test client,
such as by putting something like

debug_connection 127.0.0.10;

within the events{} block, and then looking in error_log.

> If I try the same thing in a subdirectory, it doesn't work.

Put the rewrites at server{} level, or in the location{} that is chosen.

> It seems that the "location =" that I've put to intercept the rewrite
> doesn't match.

No.

The rewrite that you want doesn't happen, because the request
/en/privacy.php is handled in:

> location ~ \.php$ {
> location / {
> location ^~ /en/ {
> location = /en/pagina.php {
> location ~ \.php$ {

....that location, and not in the one two above it.

Good luck with it,

f
--
Francis Daly francis@daoine.org

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

Rewrite rules from Apache again

Luciano Mannucci June 10, 2014 12:02PM

Re: Rewrite rules from Apache again

Francis Daly June 10, 2014 05:44PM

Re: Rewrite rules from Apache again

Luciano Mannucci June 11, 2014 12:22PM

Re: Rewrite rules from Apache again

Francis Daly June 11, 2014 01:06PM

Re: Rewrite rules from Apache again

Luciano Mannucci June 12, 2014 09:26AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 203
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