A
A
aolko2015-11-09 17:23:53
Regular Expressions
aolko, 2015-11-09 17:23:53

Regular expression to wrap from URL with certain characters to home page?

Need help with creating a regular expression for redirects from links like
sitename.ru/shop_fid_%numbers%/
sitename.ru/shop_fid_%numbers%_pn_%number%.html
sitename.ru/shop_id_%numbers%.html
sitename.ru/pn=% digit%
on sitename.ru
full .htaccess (just in case)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Belyaev, 2015-12-28
@aolko

This is a very strict redirect that falls right under the template and nothing else, and also with the 301 code, which means the page has moved to a new address

RewriteRule ^shop_f?id_[0-9]+(_pn_[0-9])?(\.html)?/?$ / [R=301,L]
RewriteRule ^pn=[0-9]+$ / [R=301,L]

But if the task is expanded and simplified, for example, to redirect
all links starting with /shop_fid /shop_id /pn, then you can generally briefly
RewriteRule ^(shop_f?id|pn).*$ / [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question