文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>网站优化之301转向的几种写法

网站优化之301转向的几种写法

时间:2009-10-22  来源:lywxm

优化过程中,我们常常遇到301转向的问题,这种处理方法在不同的情况下有不同的写法,301转向(或叫301重定向,301跳转)是当用户或搜索引擎向网站服务器发出浏览请求时,服务器返回的HTTP数据流中头信息(header)中的状态码的一种,表示本网页永久性转移到另一个地址。

JSP下的301转向代码

< %
response.setStatus(301);
response.setHeader( “Location”, “http://www.liuyiwei.org.cn/” );
response.setHeader( “Connection”, “close” );
% >

PHP下的301转向代码

header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: http://www.liuyiwei.org.cn/articles/301/”);
exit();

ASP下的301转向代码

< %@ Language=VBScript. % >
< %
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.liuyiwei.org.cn/articles/301/”
% >

ASP.Net下的301转向代码

< script. runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,” http://www.liuyiwei.org.cn/articles/301/ “);
}
< /script. >

CGI Perl下的301转向代码

$q = new CGI;
print $q->redirect(”http://www.liuyiwei.org.cn/”);
Apache下vhosts.conf中配置301转向

为实现URL规范化,SEO通常将不带WWW的域名转向到带WWW域名,vhosts.conf中配置为:
< VirtualHost *:80>
ServerName lesishu.cn
RedirectMatch permanent ^/(.*) http://www.liuyiwei.org.cn/$1
< /VirtualHost>

< VirtualHost *:80>
ServerName www.liuyiwei.org.cn
DocumentRoot /home/webseo800
< /VirtualHost>
相关阅读 更多 +
排行榜 更多 +
泡龙大闯关安卓版

泡龙大闯关安卓版

冒险解谜 下载
割草派对安卓版

割草派对安卓版

飞行射击 下载
堡垒攻防战安卓版

堡垒攻防战安卓版

飞行射击 下载