user1280853
user1280853

Reputation: 1169

nginx location redirect too many redirects

I am trying to redirect all URLS from my site /search to /search/grid

using:

    location /search {
            return 301 /search/grid;
    }

this works to redirect /search but then /search/grid gives the HTTP error too many redirects, how can I only redirect if the path is only /search?

Upvotes: 2

Views: 2045

Answers (1)

Richard Smith
Richard Smith

Reputation: 49672

Use either and exact match location block, or a rewrite:

location = /search {
    return 301 /search/grid;
}

Or:

rewrite ^/search$ /search/grid permanent;

See this and this for more.

Upvotes: 2

Related Questions