M
M
MyQuestion2021-10-18 10:05:17
htaccess
MyQuestion, 2021-10-18 10:05:17

How to make a redirect for the last url slug consisting only of numbers?

Good afternoon!

How to make a redirect for pages like:
https://site.ru/slug1/slug2/slug(n)/34584378 (any numbers)
to the same page, but without a numerical slug:
https://site.ru/slug1/slug2 /slug(n)/
Any nesting, the last slug consists of numbers only.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-10-18
@MyQuestion

At the beginning of the .htaccess file add Or
RedirectMatch 301 ^/(.+)/\d+/?$ /$1/

RewriteEngine On

RewriteRule ^(.+)/\d+/?$ /$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