详解301重定向的操作方法

2026-02-19 18:54:52

1、Apache 服务器实现301 重定向

在Apache 中,有个很重要的文件.htaccess,通过对它的设置,可以实现很多强大的功能,301 重定向只是其中之一。找到redirect permanent / http://lusongsong.com:redirect permanent /old.html http://new.com:修改这句即可。

2、在.htaccess文件中增加301重定向指令

采用“mod_rewrite”技术,形如:

RewriteEngine on

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

3、适用于使用Unix网络服务器的用户

通过此指令通知搜索引擎的spider你的站点文件不在此地址下。这是较为常用的办法。

形如:Redirect 301 / http://wdl9.com/

4、用ASP/PHP实现301重定向:

ASP:

Response.Status="301 Moved Permanently"

Response.AddHeader "Location","http://wdl9.com/"

Response.En

PHP:

header("HTTP/1.1 301 Moved Permanently");

header("Location:http://wdl9.com/");

exit();

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢