Home What 301 redirect would work for this string format?
Reply: 1

What 301 redirect would work for this string format?

user78955
1#
user78955 Published in 2018-02-08 19:44:09Z

I have an ecommerce store with the product URL format: /categoryname/subcat1name/subcat2name/1450--my-widget

I will shorten it to: /1450--my-widget

I can do the change within the ecommerce software, but I need to set up a mod rewrite redirect for the old URLs.

To avoid matching URLs for categories, content pages, etc, as well as product URLs of the new format, I need to match on all these conditions:

  1. Does not contain the string "/info/"
  2. Contains a slash, followed by 1 or more characters, followed by another slash, followed by 1 or more digits, followed by "--", followed by 1 or more characters

What directive would work?

EDIT: More examples of matching and non matching strings

Matches for old product url:

/a-category/this-category/333--my-widget
/some-cat/34--widgetname

Non matches:

/1918--widgetcategory/
/info/12--about-us
/quick-order
/login?back=my-account
/2050--my-widgetname
anubhava
2#
anubhava Reply to 2018-02-09 19:36:32Z

You can use this 301 redirect rule as your very first rule in site root .htaccess:

RedirectMatch 301 ^(?!.*/info/).*/[^/]+/([0-9]+--[^/]+)/?$ /$1
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299316 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO