English 中文(简体)
share a folder in 2 domains using .htaccess
原标题:

I got 2 sub-domains

c:wampwwwwebsiteA - http://websiteA/

c:wampwwwwebsiteB - http://websiteB/

inside websiteA got a folder for storing picture

c:wampwwwwebsiteAphotos

in order websiteB want to access websiteA photo in websiteB s html I have to do link like

url: http://websiteB/1.html

<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.

最佳回答

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.

问题回答

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





相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签