Wurstbro
Wurstbro

Reputation: 974

301 redirect all image requests from folder1 to folder2

Currently I have the following setup:

3 image folders for big | resized | thumb

domain.com/big/image1.jpg

domain.com/resized/image1.jpg

domain.com/thumb/image1.jpg

Since I want to drop the thumb and resized folder, or at least the images in them, I would like to redirect both requests to resized and thumb to big

Many of those images might be indexed by google. So maybe a 301 redirect would be best?

Also changing the .htaccess in resized and thumb would be preferred, since the root htaccess is complicated enough already :)

Goal would be to save a lot of space while merging the SEO of 3 images into 1

Upvotes: 1

Views: 208

Answers (1)

Jon Lin
Jon Lin

Reputation: 143946

Try adding these rules above any routing rules that you may already have:

RewriteEngine On
RewriteRule ^(resized|thumb)/(.*)$ /big/$2 [L,R=301]

But if you prefer to edit the htaccess files in the resized and thumb directories, you can add these to the htaccess file in those 2 directories:

RewriteEngine On
RewriteRule ^(.*)$ /big/$1 [L,R=301]

Note that by doing this, none of the rules that you have in the root htaccess file will get applied.

Upvotes: 1

Related Questions