S
S
Sheryorg2015-01-27 13:31:04
Nginx
Sheryorg, 2015-01-27 13:31:04

How to rewrite request in nginx?

Two hours of googling and trying came up with nothing.
Please tell me how to redirect a link like www.site.ru/product/?PAGEN_1=1 with a server response 301 to a link like www.site.ru/product .
At the same time, www.site.ru/product/?PAGEN_1=2 should not be redirected.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
panaceya, 2015-01-27
@panaceya

Hello!
In theory it should work like this:

if ( $request_uri ~ '^/tovar/' ) {
     return 301 "../";
}

V
Vlad Zhivotnev, 2015-01-27
@inkvizitor68sl

define "view reference".
In general:
if ( $arg_PAGEN_1 = "1" ) { return 301 http://..... ; }
Or $arg_... != "" (that is, not empty).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question