• 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?

Viewing 1 replies (of 1 total)
  • Thread Starter mydog8it

    (@mydog8it)

    I’ve gotten this to work, in case anyone else needs this:

    RewriteEngine on
    RewriteBase /
    RewriteRule ^folder-a/wp-content/uploads/2015/11/(.*)$ /folder-b/wp-content/uploads/$1 [R=301,NC,L]

    This also works:
    RedirectMatch 301 /folder-a/wp-content/uploads/2015/11/(.*) https://mydomain.com/folder-b/wp-content/uploads/$1

    I can’t figure out how to get it to strip the date folders off so I can just redirect everything in the old /uploads/ subfolders at once. If anyone has a way to do it without having to enter each month on its own line, I would very much appreciate the help.

Viewing 1 replies (of 1 total)
  • The topic ‘redirecting all image urls’ is closed to new replies.