在共享網絡託管上,我的軟件支持多個域(所有域指向相同的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