share a folder in 2 domains using .htaccess
-
22-09-2019 - |
Question
I got 2 sub-domains
c:\wamp\www\websiteA\ - http://websiteA/
c:\wamp\www\websiteB\ - http://websiteB/
inside websiteA got a folder for storing picture
c:\wamp\www\websiteA\photos\
in order websiteB want to access websiteA photo in websiteB's html I have to do link like
<img src="http://websiteA/photos/1.jpg" />
the problem is I don't want to expose websiteA domain in websiteB, since two domain is inside one machine. Is it possible to achieve something like virtual host?
I also don't want to expose the physical path for websiteA, and don't want to duplicate the data.
I am thinking do something in websiteB .htaccess?
My goal is in websiteB html able to display photo with it own domain,
<img src="http://websiteB/photos/1.jpg" />
Edit: I think the question ask it this way is better in order user request http://websiteB/photo/1.jpg, the backend actually request the file from http://websiteA/photo/1.jpg, any idea do from .htaccess?
I am new in htaccess, I tried in .htaccess, but not success
RewriteEngine On
RewriteRule http://websiteA/photos/1.jpg http://websiteB/photos/1.jpg[NC,L]
Many Thanks!!!
PS: Solution need to work either windows / linux environment.
Solution 3
I think I got my solution, not sure is perfect or not inside .htaccess for websiteB
RewriteEngine On
RewriteBase /websiteB/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^photos/(.*)$ http://websiteA/$1 [L]
the thing I found it not so perfect is when I enter http://websiteB/photos/1.jpg, it will redirect to http://websiteA/photos/1.jpg
but inside the HTML, I type
<img src="http://websiteB/photos/1.jpg" />
It able to load http://websiteA/photos/1.jpg without change the URL. That's look OK for me.
OTHER TIPS
On Windows it depends on what filesystem you're using. NTFS: http://en.wikipedia.org/wiki/NTFS_symbolic_link FAT32 doesn't support symlinks.
Sound doggy? Can you supply reason?
What you are probably looking for is a proxy. Check it out on google