regex - 301 Redirect/Rewrites with Patterns -


i know using power of regex, can reduce 301's few lines. however, not have brain power it.

basically our links went from:

http://www.site.com/collection/womens-active (this can have ?brand=123 queries attached end)

to:

http://www.site.com/collection/active

"womens-" changed part.

a simple 301 works perfectly, queries, there 100 lines in htaccess.

with regex, can reduce few lines?

use redirectmatch instead:

redirectmatch 301 ^/collection/([^/-]+)-active/(.*)$ /collection/active/$2 

assuming "is changed part", mean there says "womens-".


edit: since it's other way around, swap regex grouping , "womens-":

redirectmatch 301 ^/collection/womens-([^/-]+)/(.*)$ /collection/$1/$2 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -