Answer the question
In order to leave comments, you need to log in
Regular expression to change pattern?
Good afternoon. On the site, we change the url address for products and sections. It was respectively /catalog/section_code/, /catalog/section_code/product_id/. New page templates take the following form: /catalog/books-section_code/, /catalog/book-product_id/. I'm trying to compose a regular expression for these patterns, to redirect from the old address to the new one. Addresses like /catalog/books-text/.../ and /catalog/book-text/ should be excluded from the redirect
rule 30987/
It works as expected, but there is a nuance, that in the group I get "bookss-psihologiya/30987", but I need to get it without an id, how can I change it?
Answer the question
In order to leave comments, you need to log in
To exclude "book-" and "books-" you need to catalog/
add after(?!books?-)
RewriteRule ^(catalog)/(?!books?-)([^/]+)/$ /$1/books-$2/ [R=301,L]
RewriteRule ^(catalog)/(?!books?-)[^/]+/([^/]+)/$ /$1/book-$2/ [R=301,L]
RedirectMatch ^/(catalog)/(?!books?-)([^/]+)/$ /$1/books-$2/
RedirectMatch ^/(catalog)/(?!books?-)[^/]+/([^/]+)/$ /$1/book-$2/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question