O
O
ozoro2018-12-05 22:10:16
htaccess
ozoro, 2018-12-05 22:10:16

How to make a redirect from pages with numbers to the same without numbers through .htaccess?

Tell me, is it possible to redirect all pages that contain numbers at the beginning of the last part of the URL to the same url without numbers?
Example:

/category/category/10-page.html
/category/110-page.html
/210-page.html

redirect to:
/category/category/page.html
/category/page.html
/page.html

I would be grateful if someone could suggest a solution using htaccess

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-12-05
@dodo512

RewriteCond %{REQUEST_URI} ^(.*/)\d+-([^/]+\.html)$
RewriteRule ^ %1%2 [R=301,L]

Or so
RewriteRule ^(|.*/)\d+-([^/]+\.html)$ /$1$2 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question