在
<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 PermanentlyDate: Tue, 25 Dec 2018 09:39:44 GMTServer: Apache/2.2.15 (CentOS)Location: http://www.baidu.com/Connection: closeContent-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