URL Redirect help

I recently changed my site url from

sitename.com/doc/articles/4962/1/What-goes-up-doesnt-have-to-come-down/Page1.html

sitename.com/doc/articles/4962/what-goes-up-doesnt-have-to-come-down.html

the 4962 is contentid, articles and 1 just foldernames.

Can you please tell me what should i put in my htaccess redirect so that all old urls are 301 redirected to the new format.

i tried as follows

RedirectMatch 301 /articles/(.)/1/(.) http://www.sitename.com/articles/$1

But this only redirects to doc/articles/4962

and Google is showing this as 418 error.

Help plz.

Well you were close, but you failed to use your second capture which is important.

RedirectMatch 301 /articles/(.*)/1/(.*)/(.*).html http://www.sitename.com/articles/$1/$2.html

Thank you so much. it worked. :slight_smile: