Mod重写子域URL到根文件夹(apache)

时间:2012-05-11 21:07:50

标签: apache mod-rewrite

我目前有一条重写规则,将* .domain.com重写为www.domain.com(blog.domain.com除外)

  

RewriteEngine On RewriteCond%{HTTP_HOST} ^ domain.com $ [NC]

     

RewriteRule ^(。*)$ http://www.domain.com $ 1 [R = 301,L]

我想将所有网址从子域重写到根域,同时保留页面名称,添加“.html”扩展名,并添加[301] perm标记:

blog.domain.com/my-first-link  -->  www.domain.com/blog/my-first-link.html 
blog.domain.com/my-second-link -->  www.domain.com/blog/my-second-link.html

1 个答案:

答案 0 :(得分:1)

RewriteEngine on
RewriteRule ^(.*) http://www.domain.com/blog/$1.html [R=301,L]