Welcome! Log In Create A New Profile

Advanced

Re: Rewrite or internal redirection cycle?

May 20, 2011 01:36AM
On Thu, May 19, 2011 at 09:20:55AM -0400, TECK wrote:
> Hi,
>
> I'm having a bit of an issue with the rewrite scheme:
>
> server {
> ...
> location / {
> try_files $uri $uri/ @data;
> }
>
> location @data {
> rewrite ^ /data.php$is_args;
> internal;
> }
> ...
> }
>
> When I access this request:
> http://domain.com/information/feedback/?order=desc&sort=date
>
> I get an internal redirection cycle:
> *1 rewrite or internal redirection cycle while processing "/data.php?",
> client: IP, server: domain.com, request: "GET
> /information/feedback/?order=desc&sort=date HTTP/1.1", host:
> "domain.com", referrer: "http://domain.com/information/feedback/"
>
> However, if I access this request:
> http://domain.com/information/feedback/400028-some-information.html
>
> Everything works properly. What do you recommend to do, in order to
> troubleshoot the issue?
> My goal is to actually log what goes wrong with the php code, when the
> redirection cycle is encountered.
>
> Thanks for your help.

You should either add "break" to stop internal redirection cycle:

location @data {
rewrite ^ /data.php$args break;
}

or should define /data.php in try_files

location / {
try_files $uri $uri/ /index.php?$args;
}

or (my favorite) should define exactly what nginx should do in @data:

location @data {
fastcgi_pass ...
fastcgi_param SCRIPT_FILENAME /path/to/data.php;
...
}

The later way looks more complex at the first sight, but it creates
independed locations and allows configuration to grow at very large scale.


--
Igor Sysoev

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

Rewrite or internal redirection cycle?

TECK May 19, 2011 09:20AM

Re: Rewrite or internal redirection cycle?

Igor Sysoev May 20, 2011 01:36AM

Re: Rewrite or internal redirection cycle?

TECK May 20, 2011 02:40PM

Re: Rewrite or internal redirection cycle?

muhfiasbin June 15, 2011 09:11AM

Re: Rewrite or internal redirection cycle?

SplitIce June 15, 2011 09:24AM

Re: Rewrite or internal redirection cycle?

António P. P. Almeida June 15, 2011 10:38AM

Re: Rewrite or internal redirection cycle?

António P. P. Almeida June 15, 2011 10:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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