张力-实战网络营销导师
专注于网络营销推广+Wordpress建站,只做有思想的高价值网站,只提供有担当的营销服务!
文章496浏览3640090本站已运行1360

301永久重定向的好处及几种做法

301永久重定向:这是SEO中的一个基础名词,在URL规范化中会用到,也许大家都知道这个名词,但是由于应用的不是非常频繁,导致很多专业做SEO的朋友都不是很熟悉301永久重定向的具体操作方法,今天武汉seo疯子就讲解下301永久重定向的理论,以及实际的操作方法。

301永久重定向是所有的重定向方法中唯一符合搜索引擎规则的重定向方法,其他的重定向还包括302暂时重定向和JS跳转等,这些方式都容易导致URL不规范问题的产生。所以说如果你有多个域名都希望可以让他们访问同一个网站,那就只能将其中一个做为主域名,剩下的其他域名做301永久重定向到这个主域名,只有这样才可以完美的让多个域名都访问一个站点,不会产生重复收录,导致网站被惩罚的现象。

下面武汉seo疯子就给大家说一下几种301定向的做法:

一、利用网站修改网站的伪静态规则来实现301定向,如下:

1、httpd.ini伪静态规则的301定向方法

修改httpd.ini文件的代码如下:

[ISAPI_Rewrite]

CacheClockRate 3600

RepeatLimit 32

RewriteCond Host: ^59seo\.com$

RewriteRule (.*) http\://www\.59seo\.com$1 [I,R]

2、.htaccess伪静态规则的301定向方法

修改.htaccess文件的代码如下:

RewriteCond %{HTTP_HOST} !^www.zhangliseo.com$ [NC]
RewriteRule ^(.*)$ http://zhangliseo.com/ $1 [L,R=301]

第二种就是武汉seo疯子用过的两种程序的伪静态设置,一个是织梦CMS,一个zlbog程序。

1、织梦CMS的301定向做法如下:

第一步:把DedeCMS根目录下index.php原文件换成以下内容:

<?php
$HOST=$_SERVER['HTTP_HOST'];
if ($HOST=="不带WWW的域名" || $HOST=="空间赠送的域名"){
Header("HTTP/1.1 301 Moved Permanently");
Header("Location:http://带WWW的域名");
exit();
}

if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
{
    header('Location:install/index.php');
    exit();
}
//自动生成HTML版
require_once (dirname(__FILE__) . "/include/common.inc.php");
require_once DEDEINC."/arc.partview.class.php";
$GLOBALS['_arclistEnv'] = 'index';
$row = $dsql->GetOne("Select * From`dede_homepageset`");
$row['templet'] = MfTemplet($row['templet']);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
$pv->Display();
?>  

上传并覆盖。

第二步:进入空间控制面版,把默认首页更改成index.php,刷新即可看到301重定向的效果。

2、Zblog的301定向做法如下:

在网站根目录下default.asp里面开头找到以下代码之间:
<!-- #include file="function/c_system_plugin.asp" -->
<!-- #include file="plugin/p_config.asp" -->
<%
<之间加入以下代码>
if request.ServerVariables("SERVER_NAME")=" 59seo.com" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", " www.59seo.com"
Response.End
end if
<之间加入以上代码>
If (InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml") > 0) And (InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/html") = 0)  Then Response.Redirect "wap.asp"
其中 www.zhangliseo.com 和 http://zhangliseo.com 替换成你自己的网址就可以了。

 

您还未添加分享代码,请到主题选项中,添加百度分享代码!

张力


Warning: Undefined variable $comment_i in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/comments.php on line 19
广告
发表我的评论
取消评论
表情 签到
流汗坏笑撇嘴大兵流泪发呆抠鼻吓到偷笑得意呲牙亲亲疑问调皮可爱白眼难过愤怒惊讶鼓掌

Hi,您需要填写昵称和邮箱!

(4)个小伙伴在吐槽
  1. 数码相机什么牌子好
    数码相机什么牌子好
    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 141

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 151

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 156

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 161
       未知   未知
    2012-06-17 15:35

    谢谢博主分享!

    武汉seo疯子 于 2012-6-17 16:06:55 回复

    谢谢,希望常来看看,疯子每日都更新的!

  2. 云电商
    云电商
    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 141

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 151

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 156

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 161
       未知   未知
    2012-06-17 13:47

    301重定向的事情网上有很多内容。博主。。。发点干货吧!

    武汉seo疯子 于 2012-6-17 14:50:26 回复

    呵呵,我博客的文章都是我自己写的,很多都是我遇到的事情写了下来!

  3. 小云子
    小云子
    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 141

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 151

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 156

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 161
       未知   未知
    2012-06-16 16:36

    过来学习学习

    武汉seo疯子 于 2012-6-17 9:35:37 回复

    大家一同学习,呵呵!

  4. 吴克难的博客
    吴克难的博客
    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 141

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 151

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 156

    Warning: Undefined variable $useragent in /www/wwwroot/zhangliseo/wp-content/themes/ZL-ZMT/functions/admin/comment.php on line 161
       未知   未知
    2012-06-16 11:05

    谢谢博主精彩分享!

    武汉seo疯子 于 2012-6-17 9:35:20 回复

    大家一起学习,共同进步嘛!

隐藏边栏