I need to redirect a large amount of pages that have added random numbers onto the end of the page urls, I need to redirect these pages to a single url but there will be a large amount of urls throughout the website eg;
http://www.domain.com/a002-product-ring-50134.html
http://www.domain.com/a002-product-ring-50140.html
http://www.domain.com/a002-product-ring-50145.html
http://www.domain.com/a002-product-ring-50168.html
http://www.domain.com/a002-product-ring-50384.html
http://www.domain.com/a002-product-ring-50393.html
http://www.domain.com/a002-product-ring-50404.html
These need redirecting to http://www.domain.com/a002.html but the only thing i need to query is the number so something like this is what I thought would work;
Redirect 301 /a002-product-ring-(*).html http://www.domain.com/a002.html
您需要将RedirectMatch
用于正则表达式功能:
RedirectMatch 301 (a.+?)-product-ring-[^.]+\.html$ http://www.domain.com/$1.html
We can use RewriteCond and match the uri pattern as following.
RewriteCond %{REQUEST_URI} ^.*(hello.html|contact_us.php)$
RewriteRule ^/(.*) http://www.domain.com/a002.html [R=302,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.