使用.htaccess将所有子域名网址重定向到特定网址

时间:2011-10-15 19:13:46

标签: .htaccess mod-rewrite

如何重写

(anything).example.com/(anything)example.com/(anything)

例如:

img1.example.com/test1.jpgexample.com/test1.jpg

img105.example.com/anotherimage.pngexample.com/anotherimage.png

tdr.example.com/a.cssexample.com/a.css

1 个答案:

答案 0 :(得分:0)

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