E
E
ervik2019-04-08 20:49:24
Nginx
ervik, 2019-04-08 20:49:24

How to make redirects to nginx at the end of the url?

Greetings!
There is a pack of urls (more than 200 pieces with changing numbers at the end) with parameters, example:
site.ru/index.php?route=product/category&path=90_128 You
need to make a 301 redirect to another site (gluing, target pages have different addresses ).
Because of the question mark, the conditions do not pass.
I wanted to do it through location, at the end of the url (path=90_128) - that doesn't work either.
How to make conditions for location for such url?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Mezhuev, 2019-04-08
@mezhuev

And it won't work because it locationuses the normalized URI and no arguments. With rewritea similar situation. A simple solution to the problem:

location /index.php {
    if ($arg_path ~ "^[0-9]{2}_[0-9]{3}$") {
        return 301 https://example.com/;
    }
}

The regular schedule should be corrected for the real state of affairs. And remember, If Is Evil ! It would be more correct to implement through ngx_http_map_module , but without seeing the whole picture it is difficult to advise.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question