B
B
bossigorxxx2020-12-09 12:16:03
htaccess
bossigorxxx, 2020-12-09 12:16:03

How to make a redirect if at the end of the number?

Hello! There are such links /kak-ukrasit-interer-rakushkami/32-3/ it is necessary to redirect to /kak-ukrasit-interer-rakushkami/ Is there a solution? I tried this:
RewriteEngine On
RewriteRule ^(.+)\-\d+/$ /$1/ [R=301,L] But the first digits, like 32, for example, do not remove,

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-12-09
@bossigorxxx

Purely according to

RewriteRule ^kak\-ukrasit\-interer\-rakushkami/32\-3/$ /kak\-ukrasit\-interer\-rakushkami/? [L,R=301]

But if you have only two digits dash 1 digit
https://regex101.com/r/5I0rz0/1
But if the syntax is any number of dash digits any number of digits
https://regex101.com/r/5I0rz0/2
A here is most likely what you need
https://regex101.com/r/5I0rz0/4
[^\/]+ - any number of characters but not a slash
[0-9]{1,}- numbers from zero to nine from one time or more
(\/|)- a slash or its absence at the end (optional)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question