Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 417
CMOS Avatar asked Oct 20 '22 10:10

CMOS


1 Answers

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]
like image 178
anubhava Avatar answered Oct 24 '22 12:10

anubhava