Redirection problem again in new rules.

Francis Daly francis at
Fri Apr 15 16:35:45 UTC 2016

On Fri, Apr 15, 2016 at 12:27:11PM +0500, Muhammad Yousuf Khan wrote:

Hi there,

> Sorry for the mistake in a's and b's i was typing that in general because
> the context was not the URL but the problem.

If you can show one specific url which does show the problem, then it
makes it much easier to see what is going on.

If you can also include one small but complete config file that shows
the problem, that makes it much easier for someone else to repeat your

(And sometimes, the act of making a small config that shows the problem,
will show you what the fix is.)

> >Do note that "location /x" can match anything that starts with /x; and
> >if a request for /x.html returns a redirect to /x.html, you've got a loop.
> Yes , i have double checked but my redirection rules are not created wrong.
> so i am sure no loop is happening there.

Part of the point of you asking the question, is that you do not know
where the problem is.

So usually, the best thing is to run a test nginx with your config, then
remove as much as possible while still showing the problem. Maybe that
config will just have two location{} blocks, and the loop will be obvious.

> BTW just to update you guys. i am using wordpress.
> i am doing two redirections , one domain base and second URL base.
> domain base is working fine however URL redirections are giving me issues.

Use "curl" to test your broken url and see what exactly is returned.

Do something like

  curl -i http://your-server/aaaa/bbbbbbbb

and you should get a http 301 response, with something in the Location:

Then do "curl -i" against that url, and see if you get the loop.

The *rest* of the headers may show that PHP was, or was not, involved
in the redirections.

> could this be related to wordpress?

It could be.

If the "curl" responses show that PHP is involved, then it probably is.

Francis Daly        francis at

More information about the nginx mailing list