redirecting all image urls
-
I have an old wordpress site installed in folder A. I’d like to redirect to the new wordpress site. It’s installed in folder B, but I plan on running it on the root from there. Folder A will be deleted. Images on the new site have the same names, but I’m not organizing by date, so the urls will all change.
What’s the best way to handle redirecting all the images via htaccess? I’ve come across these options:
RewriteRule ^folder-a/wp-content/uploads/2015/11/(.*)$ /wp-content/uploads/$1 [R=301,NC,L] RewriteRule ^folder-a/wp-content/uploads/2015/11/(.*)$ /folder-b/wp-content/uploads/$1 [R=301,NC,L] RedirectMatch 301 /folder-a/wp-content/uploads/2015/11/(.*) /wp-content/uploads//$1 RedirectMatch 301 /folder-a/wp-content/uploads/2015/11/(.*) /folder-b/wp-content/uploads//$1
I’m not sure which is the best option (if either?) and whether or not I need to have the new folder location in the url, or if it should redirect to the root? Also, is there a way to do this that will grab all of the sub-folders under /uploads/ or do I need to do each date sub-folder separately?
- The topic ‘redirecting all image urls’ is closed to new replies.