Drupal htaccess redirect - all files in directory to new directory
- by hfidgen
Hiya,
I've moved a site to Drupal, but am now getting a lot of 404 errors due to the search engines taking their time to update the indexes.
The 404 paths all look similar to this:
recipedata/ccp1300006/633_L.jpg
recipedata/ccp1500005/risotto.jpg
recipedata/ccp1500006/haddock.jpg
So I'd like to do some htaccess redirection with mod_rewrite to take care of this lot. All the images DO exist - the path has just changed to /sites/default/files/images/
I've edited a lot of redirects into my htaccess already, but because the ccpXXXXXX directory changes I can't quite figure out the regex.
This was my last attempt, but yeah - doesn't work :) Can anyone give me some pointers?
RewriteRule ^recipedata/(ccp+)/(.+)$ http://domain.co.uk/sites/default/files/images/$2 [R=301,L]
This has to be in the context of the Drupal mod_rewrite rules which already exist
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
Thanks!