Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess redirect for images from old folder to new folder

Tags:

.htaccess

I have just moved from Drupal + Wordpress to a site completely built in WordPress.

Duly I have a set of images where the files no longer exist and need to try and keep all the images in the one folder (if possible). Duly I need to send requests for any gif|png|jpg that are for http://www.domain.com/blog/wp-content/uploads/ to http://www.domain.com/wp-content/uploads.

If anyone could help would be appreciated - my .htaccess aint what it once was. Thanks in advance

like image 345
Michael Avatar asked Mar 20 '11 01:03

Michael


1 Answers

If you google for "htaccess redirect", the top link is this:
http://www.htaccessredirect.net/

If you use the "301 Redirect Directory" section, you get this code:

//301 Redirect Entire Directory
RedirectMatch 301 /blog/wp-content/uploads/(.*) /wp-content/uploads/$1

As far as I know the target domain should be absolute, so the following might work:

//301 Redirect Entire Directory
RedirectMatch 301 /blog/wp-content/uploads/(.*) http://www.domain.com/wp-content/uploads/$1
like image 104
user523736 Avatar answered Sep 19 '22 03:09

user523736