使用htaccess从远程服务器提供文件

有没有可能使用htaccess来做到这一点?

用户访问 – > http:// mydomaina.com/dir/filename

它将显示 – > http:// mymainsite.com/anydir/mydomaina-filename的内容

我有一个htaccess的代码,但它不能正常工作,可能是缺less的东西

<IfModule mod_rewrite.c> RewriteRule ^dir/(.*)\.xml$ http://mymainsite.com/dir/%{HTTP_HOST}-$1.xml [P] </IfModule> 

谢谢

我RTFM编辑。 它说:

 ^/somepath(.*) /otherpath$1 [P] doesn't make sense, not supported ... ^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo via internal proxy 

所以它看起来应该工作。 但..

 Note: mod_proxy must be enabled in order to use this flag. 

它不工作

这不是一个有意义的错误信息。 你的日志文件显示什么? 如果您尝试发送redirect而不是代理,会发生什么情况?

C。

首先想到的是mod_rewrite没有打开。 只需加载模块是不够的。 在你的configuration的某个地方,你也需要RewriteEngine On来启用它。

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteengine