Cj Belo
Cj Belo

Reputation: 51

How can I rewrite image path via htaccess?

I have two websites e.g.,

example1 is already up and has all the images I need to put in my example2 website.

i want to get all images from example1 to put in my example2 website e.g.,

www.example1.com/media/img/image1.jpg <-- get this image and put in www.example1.com/media/img/image2.jpg

I want this done so that I don't have to copy all images from example1 directory to example2

Thank you all... :)

Upvotes: 1

Views: 2463

Answers (1)

anubhava
anubhava

Reputation: 784958

Enable mod_rewrite and .htacces. Then put this code in your .htaccess under DOCUMENT_ROOT:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

#RewriteCond %{HTTP_HOST} ^(www\.)?example2\.com$ [NC]
RewriteRule ^media/img/ http://www.example1.com%{REQUEST_URI} [L,R=301,NC]

Upvotes: 1

Related Questions