I’m converting a site over from WordPress to a custom CMS and I’m trying to figure out how to handle all of the image paths that are within posts.
The URL structure is http://site.com/wp-content/uploads/2012/09/image-name.jpg
I need to get it in the form of http://site.com/uploads/image-name.jpg
This is what I’ve got so far:
RewriteRule ^wp-content/uploads/([0-9-])/([0-9-])/([A-Za-z0-9-_]+)/?$ uploads/$3 [R=301,L]
It doesn’t seem to be working though, what am I doing wrong?
Almost. You’re middle to groupings only match a single digit or
-. You need a+after them:And you’ll want a slash before
uploads/and you need to include a.as part of the final grouping (to match the extension).