H
H
herprogrammist2020-03-04 17:03:09
URL Handling
herprogrammist, 2020-03-04 17:03:09

How to make nginx 301 redirect from pages with / to pages without /?

How to set up 301 redirects to pages without a closing one for specific subsections of the site /
What mask is needed for this? (pages like pagex-pagexxx)

Examples of subsections/pages
https://domen.ru/razdel?page=1/
https://domen.ru/razdel?page=12/
https://domen.ru/razdel?page =123/
etc.
you need
https://domen.ru/razdel?page=1
https://domen.ru/razdel?page=12
https://domen.ru/razdel?page=13

2) for pages like
https://domen .ru/razdel/podrazdel?page=1/
https://domen.ru/razdel/podrazdel?page=12/
https://domen.ru/razdel/podrazdel?page=123/ https://domen
.
ru/razdel/podrazdel?page=1
https://domen.ru/razdel/podrazdel?page=12
https://domain.ru/section/subrazdel?page=123

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-03-04
@herprogrammist

RewriteCond %{QUERY_STRING} ^(page=\d+)/
RewriteRule ^razdel($|/).* /$0?%1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question