2013-03-26 73 views
2

我想爲.htaccess重定向圖像/的icon.png添加到文件名的圖像/ [子網域] _icon.png ..的.htaccess重定向[子網域] +

,如:

demo.domain.com/images/icon.png to demo.domain.com/images/demo_icon.png 
test.domain.com/images/icon.png to test.domain.com/images/test_icon.png 
abc.domain.com/images/icon.png to abc.domain.com/images/abc_icon.png 

重定向應該是通用的,不是固定不變的..任何子域應該_icon.png被添加..

[subdomain].domain.com/images/icon.png -> [subdomain].domain.com/images/[subdomain]_icon.png 

請指教..

回答

1
RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTP_HOST} ([^.]+)\.yourdomain\.com$ [NC] 
RewriteRule ^images/icon\.png http://%1.yourdomain.com/images/%1_icon.png [R=301,L] 

這個例子需要測試...

+0

其工作.. gr8 – Jahanzeb 2013-03-26 07:29:48