Apache Rewrite for Subdomain Images

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

I found an example on other issues

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

But since I'm pretty new to mod_rewrite, I'm not sure what is going on or how to manipulate it to work for me.

+5
source share
1 answer

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

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

All Articles