Linux 系统 Apache 301 重定向配置方法

例如,要把域名 test.com,重定向到 www.test.com,则需要修改 Apache 中站点的配置文件,添加 301 重定向的配置。

最主要就是以下配置:

 

1 ServerName test.com        #绑定的域名test.com
2 RedirectMatch  permanent  ^/(.*)  http://www.test.com/$1       #访问test.com,都跳转到www.test.com 

 

 

添加好 Apache 的配置后,重启 Apache 生效,然后访问 test.com,就会 301 跳转到 www.test.com :

 

posted @ 2017-06-07 15:08  cnbing  阅读(3504)  评论(0编辑  收藏  举报