Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess文件未将资产重定向到其他域_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

.htaccess文件未将资产重定向到其他域

.htaccess文件未将资产重定向到其他域,.htaccess,redirect,mod-rewrite,.htaccess,Redirect,Mod Rewrite,我试图让我的PHP站点使用.htaccess文件中的重定向从另一台服务器上拉入/assets/u/中的图像。.htaccess肯定正在使用中。我知道这一点,因为我在HTTPD config的sites根目录中设置了'AllowOverride All',甚至测试了它,故意输入了错误的语法,并确认我收到了一个内部服务器错误。但是/assets/u/中的我的图像仍然没有从另一台服务器中提取。下面是我的.htaccess文件 SetEnv APPLICATION_ENV production Rew

我试图让我的PHP站点使用.htaccess文件中的重定向从另一台服务器上拉入/assets/u/中的图像。.htaccess肯定正在使用中。我知道这一点,因为我在HTTPD config的sites根目录中设置了'AllowOverride All',甚至测试了它,故意输入了错误的语法,并确认我收到了一个内部服务器错误。但是/assets/u/中的我的图像仍然没有从另一台服务器中提取。下面是我的.htaccess文件

SetEnv APPLICATION_ENV production

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^((www)|(draft))\.
RewriteRule ^(.*?)\/*$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Start of attempted redirect #
RewriteCond %{REQUEST_URI} ^.*(/assets/u/).*$ [NC]
RewriteRule ^assets/(.*)$ http://assets.otherserver.com/$1 [L,R=301]
# End of attempted redirect #

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

使用
RewriteBase
指令时,请尝试删除第一个
/

RewriteCond %{REQUEST_URI} ^(assets/u/).*$ [NC]

我不完全理解你的问题,但这是我的第一次尝试

我假设您使用
资产/u/
作为
标记中的链接,并且您的实际文件存储在
http://assets.otherserver.com
地址

对于此任务,我建议您使用
mod_proxy
来显示图像,而不重定向URL。请尝试以下规则。我假设您能够在不违反其他规则的情况下安排.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/assets/u/(.+?)$
RewriteRule ^ http://assets.otherserver.com/%1 [P,L]
要使上述规则起作用,您必须启用以下选项

LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_module modules/mod_proxy.so
取消httpd.conf中上述行的注释


任何更新都请通知我。

请清楚地解释您的问题您想从另一台服务器获取图像或将特定url重定向到另一台服务器?@AbhishekGurjar我想从另一台服务器获取图像fetch表示您想从另一台服务器显示图像,或者您想下载图像或重定向到服务器图像?@AbhishekGurjar。。。显示来自其他服务器的图像。