A
A
Alexander2016-10-28 18:48:51
Nginx
Alexander, 2016-10-28 18:48:51

How to make a redirect from one page segment to another?

Hello!
I had to shorten the url of all materials to a shorter one.
It was: site.ru/news/item/{url of material}
It became: site.ru/news/{url of material}
How to make a redirect so that all requests are redirected from "was" -> "became". Well, of course, so that search robots understand this matter.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2016-10-28
@BuriK666

location ~ ^/news/item/(?<url>.*)$ {
    return 301 /news/$url$is_args$args;
}

R
romy4, 2016-10-28
@romy4

301st

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question