首页 > Web开发 > 详细

Apache 配置301跳转

时间:2018-12-25 19:55:34      阅读:157      评论:0      收藏:0      [点我收藏+]
首先确定加载了mod_alias 模块

<Directory > 
..................
        Redirect permanent "^/abc.html$" "/"
        Redirect permanent "/ccc" "http://www.baidu.com"
</Directory> 

这样配置后当访问站点 /ccc目录时就会301跳转至百度 或是访问首页下的abc.html 文件时就会跳转至根目录

效果让下:

[root@bogon log]# curl  -I http://www.mqchina.org/ccc/
HTTP/1.1 301 Moved Permanently
Date: Tue, 25 Dec 2018 09:39:44 GMT
Server: Apache/2.2.15 (CentOS)
Location: http://www.baidu.com/
Connection: close
Content-Type: text/html; charset=iso-8859-1

注意:

permanent                   
                返回一个永久性重定向状态码(301),表示此资源的位置变动是永久性的。
temp
                    返回一个临时性重定向状态码(302),这是默认值。
seeother
                    返回一个“参见”状态码(303),表示此资源已经被替代。

参考官方说明:http://httpd.apache.org/docs/current/mod/mod_alias.html#redirect

Apache 配置301跳转

原文:http://blog.51cto.com/1inux/2335183

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!