Artem  Ryzhov
Artem Ryzhov

Reputation: 23

Nginx rule for redirection error

I need to setup redirect rules for specific urls - I'm using NGINX.

Basically Something like this:

http://example.com/ --> http://example.com/maps

I' am trying:

location / {
proxy_pass http://maps-testmk;
include /etc/nginx/proxy_params;
return 301 http://maps-testmk.mgr.ru/maps;
}

}

but I have - 500 err

Upvotes: 2

Views: 43

Answers (2)

Rustam
Rustam

Reputation: 11

May be like this:

location = / {
    return 301 http://maps-testmk.mgr.ru/maps;
}
location / {
    proxy_pass http://maps-testmk;
    include /etc/nginx/proxy_params;
}

Upvotes: 1

Richard Smith
Richard Smith

Reputation: 49812

You can identify specific URLs by using the location = syntax. For example:

location = / {
    return 301 /maps;
}

location / {
    proxy_pass http://maps-testmk;
    include /etc/nginx/proxy_params;
}

Only the URI / is redirected to /maps. All other URIs (including /maps) is sent upstream.

See this document for details.

Upvotes: 0

Related Questions