好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

DedeCMS系统301重定向配置方法 - DeDecms

DedeCMS系统301重定向配置方法

301对于做网站优化的人来讲并不陌生了,像很多网站你访问不带www的会直接跳到www的网址去,这样就会有一个301配置了,如果你用站长工具查会发现是一个301状态代码,这个就是告诉搜索引擎权限给予www,下面我们一起来看看dedecms配置方法,希望文章对各位有帮助.

一、Linux系统下如何设置301重定向

1、建立一个记事本文档,然后点击[文件]--[另存为],[保存类型]选择[所有文件],文件名为 .htaccess 就可以,这样不会强制要求输入文件名.

2、用记事本打开刚才新建的 .htaccess 文件,将下面的代码复制进去:

Options +FollowSymLinks  RewriteEngine on  rewritecond %{http_host} ^phpfensi[nc]  rewriterule ^(.*)$ http://HdhCmsTestphpfensi测试数据/$1 [ r = 301 ,nc] 

3、把网址替换成您的网址,然后保存上传你网站的根目录,这个时候你会发现在你IE地址栏里输入根域名就会跳转到www这个域名.

二、Windows系统下如何设置301重定向并去掉html, 将下面的代码直接替换根目录下面的 index.php 文件,代码如下:

<?php  $HOST = $_SERVER [ 'HTTP_HOST' ];  if  ( $HOST == "429006测试数据" ||  $HOST ==HdhCmsTestphpfensi测试数据"{  Header( "HTTP/1.1 301 Moved Permanently" );  Header( "Location:http://HdhCmsTestphpfensi测试数据" );  exit ();  }  if (! file_exists (dirname( __FILE__ ). '/data/common.inc.php' ))  {  header( 'Location:install/index.php' );  exit ();  }  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();  ?> 

或者使用下面的代码:

<?php  $jump301 =1; //是否开启301跳转开关,1开 0关   $index_file = 'index.html' ; //首页文件 不支持SSI(shtml/shtm)   if ( substr ( $_SERVER [ 'SERVER_NAME' ],0,4)!= 'HdhCmsTest' && $jump301 )  {  header( 'HTTP/1.1 301 Moved Permanently' );  header( 'Location:http://HdhCmsTest' . $_SERVER [ 'SERVER_NAME' ]);  exit ();  }  if (! file_exists (dirname( __FILE__ ). '/data/common.inc.php' ))  {  header( 'Location:install/index.php' );  exit ();  }  //自动生成HTML版   if (isset( $_GET [ 'upcache' ]))  {  require_once  (dirname( __FILE__ ) .  "/include/common.inc.php" );  require_once  DEDEINC. "/arc.partview.class.php" ;  $GLOBALS [ '_arclistEnv' ] =  'index' ;  $row  =  $dsql ->GetOne( "Select * From `detest_homepageset`" );  $row [ 'templet' ] = MfTemplet( $row [ 'templet' ]);  $pv  =  new  PartView();  $pv ->SetTemplet( $cfg_basedir  .  $cfg_templets_dir  .  "/"  .  $row [ 'templet' ]);  $pv ->SaveToHtml(dirname( __FILE__ ). '/' . $index_file );  include (dirname( __FILE__ ). '/' . $index_file );  exit ();  }  include (dirname( __FILE__ ). '/' . $index_file );  ?> 

总结:其实最简单办法就是在服务器上做301,比起代码修改要简单很多.

查看更多关于DedeCMS系统301重定向配置方法 - DeDecms的详细内容...

  阅读:59次