Redirect loop fixed, I need a better rule format

TECK nginx-forum at
Mon Dec 23 06:13:14 UTC 2013

Hello everyone,

I have a little problem on hand, related to redirect loop for a specific
server {
listen spdy ssl default_server;
location ^~ /alpha {
    return 301$request_uri;
I would like to redirect URL's of this format:[more of $request_uri]
To:[more of $request_uri]

I can access fine the directory. When the
GET is performed on, it tries to use the old
REQUEST URI which is obviously wrong. I solved the issue this way:
location ^~ /alpha {
    location /alpha {
        return 301;
    location ~ ^/alpha/(.+)$ {
        return 301$1;

Is there a better (more compact) way to achieve the same results?
With the rules listed above, I tell Nginx to redirect /alpha or /alpha/ to
If the $request_uri contains something after /alpha, I grab the part of
$request_uri after /alpha and push it to /.

Thank you for helping me make this configuration part better.

Posted at Nginx Forum:,245780,245780#msg-245780

More information about the nginx mailing list