共享使用的.htaccess在2域的文件夹 [英] share a folder in 2 domains using .htaccess

查看:107
本文介绍了共享使用的.htaccess在2域的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了2分领域

C:\瓦帕\的www \ websiteA \ - 的http:// websiteA /

C:\瓦帕\的www \ websiteB \ - 的http:// websiteB /

里面websiteA得到了一个文件夹来存储图片

C:\瓦帕\的www \ websiteA \照片\

为了websiteB要访问websiteA照片websiteB的HTML我必须做的链接像

网址: HTTP://websiteB/1.html

 < IMG SRC =HTTP://websiteA/photos/1.jpg/>
 

问题是我不希望暴露websiteA域websiteB,因为两个域是一台机器里面。是否有可能实现类似虚拟主机?

我也不想暴露的websiteA的物理路径,并没有要复制的数据。

我想做点什么websiteB的.htaccess?

我的目标是在websiteB HTML能够与它显示的照片自己的域名,

 < IMG SRC =HTTP://websiteB/photos/1.jpg/>
 

  

编辑:我觉得这个问题问它这个   方法是为了用户要求更好    HTTP://websiteB/photo/1.jpg 中,   后端实际上请求从文件    HTTP://websiteA/photo/1.jpg ,任何想法从的.htaccess做

我是新htaccess的,我想在.htaccess,但没有成功。

  RewriteEngine叙述上
重写规则的http://websiteA/photos/1.jpg HTTP://websiteB/photos/1.jpg [NC,L]
 

非常感谢!

PS:解决方案需要解决的是Windows / Linux环境

解决方案

我觉得我得到了我的解决方案,不知道是完善与否 里面的.htaccess的websiteB

  RewriteEngine叙述上
的RewriteBase / websiteB /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^照片/(.*)$的http:// websiteA / $ 1 [L]
 

我发现它不是那么完美的事情是,当我进入 HTTP://websiteB/photos/1.jpg ,它会重定向到的 HTTP://websiteA/photos/1.jpg

但是HTML里面,我键入

 < IMG SRC =HTTP://websiteB/photos/1.jpg/>
 

它能够装载 HTTP://websiteA/photos/1.jpg 不改变的URL。这是找我确定。

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

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.

这篇关于共享使用的.htaccess在2域的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆