I have changed the permalink structure for a wordpress site from
Day and name http://www.domain.com/2016/12/17/sample-post/
to
Post name http://www.domain.com/sample-post/
using the following htaccess rewrites, which do work:
RedirectMatch 301 ^/[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}/(.*)$ http://www.domain.com/$1
RedirectMatch 301 ^/[0-9]{4}/[0-9]{2}/(.*)$ http://www.domain.com/$1
RedirectMatch 301 ^/(.*)/[0-9]{4}/[0-9]{2}/(.*)$ http://www.domain.com/$1/$2
however the problem now, is that its rewriting image URLs as well, example:
http://www.domain.com/wp-content/uploads/2016/12/Lego-2.jpg
is now redirecting to
http://www.domain.com/wp-content/uploads/Lego-2.jpg
which is breaking images. How can I exclude wp-content/uploads from the RedirectMatch htaccess rules.