在共享网络托管上,我的软件支持多个域(所有域指向相同的public_html根目录)。每个域都有自己的画廊(在画廊目录中)。由于多个域不能在所有站点的同一目录中拥有自己的资源(例如图像),因此我的根目录与每个HTTP主机名匹配。这里是目录结构的样子......Apache Rewrite:%{HTTP_HOST}目录中的域专用图库图像
/的public_html/
/public_html/.htaccess
/的public_html /画廊/
/public_html/www.example1.com /gallery/topic_x/image.png
/public_html/www.example2.com/gallery/topic_y/image.jpg
/public_html/www.example3.com/gallery/topic_z/image.gif
的请求......
...需要重写到...
/public_html/www.example1.com/gallery/topic_x/image.png
这需要使用.htaccess文件完成,如上所述,HTTP主机匹配目录中没有.htaccess文件(/public_html/www.example1.com/.htaccess不存在)。
我一直在试图用下面的许多修改...
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^(gallery)(/.+\.(gif|jpg|png))$ %{HTTP_HOST}$1$2 [L,NC]
...没有成功。
我很乐意作出任何澄清以及投票并接受所需工作解决方案的答案。
感谢发布! – John 2012-02-17 07:06:14