CMOS
CMOS

Reputation: 2907

Apache Rewrite for images on subdomain

I have a webserver and a subdomain. All of my images are stored in /public/images within my site directory for www.mysite.com. However I have a separate site directory for testing beta.mysite.com however on this page with a different git branch all of my images are broken because I did not want to copy all of the images. Is it possible to say for all image requests or for all 404 requests try looking at mysite.com?

I have found an example on another questions

RewriteEngine On
RewriteCond %{HTTP_HOST} ^test.example.com$
RewriteRule ^images/(.*)$ http://example.com/sub_ds/test/images/$1

But since I am rather new to mod_rewrite im not sure what is going on or how to manipulate it to work for me.

Upvotes: 5

Views: 160

Answers (1)

anubhava
anubhava

Reputation: 784908

You can use this rule in root .htaccess of beta subdomain:

RewriteEngine On

RewriteCond %{HTTP_HOST} =beta.example.com
RewriteRule ^(images/.+)$ http://example.com//public/$1 [L,NC,R=301]

Upvotes: 3

Related Questions