Htaccess 301 redirect and regular expression problem


I am new here and was advised to join to see if anyone could help.

I need to write a htaccess rule that redirects URLs that follow a certain string, to a new more appropriate URL.

However there is a problem in that the pages i want to redirect also have subpages within them.

e.g. I want to redirect this URL to this URL

I then will replicate this for all designer pages which is an easy task and a simple rule to write. However on those ‘-all’ pages are options that allow the user to filter products but creates brand new URLs like this:

This problem then replicates across all designer pages and there are too many to do this manually.

How can i use reg ex’s to write a rule that says when URL ends in ‘/tops’ or ‘/bags’ and is part of URL folder ending with ‘-all’ then redirect to xxxx page?

Thanks for any help in advance.

Hi Keir_SL,

Welcome to Sitepoint!

Are the categories such as ‘tops’ and ‘bags’ parameter on your un re-written URL, like [noparse]‘tops’[/noparse] or are these statically constructed links like [noparse]’[/noparse]?



First, Welcome to SitePoint!

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too. Come back with your attempt and I can walk you through what might be missing.