keir_sl — 2013-01-25T05:13:47-05:00 — #1
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 www.example.com/womens/designer-1-all to this URL www.example.com/womens/designer-1
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.
serverstorm — 2013-01-25T10:25:54-05:00 — #2
Welcome to Sitepoint!
Are the categories such as 'tops' and 'bags' parameter on your un re-written URL, like www.example.com/designer-1-all.html?cat='tops' or are these statically constructed links like www.example.com/designer-1-all/tops.html'?
dklynn — 2013-01-25T19:59:00-05:00 — #3
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.