主页 > 网站建设 > 建站知识 > dedecms如何正确设置301教程

dedecms如何正确设置301教程

POST TIME:2018-10-30 22:14

适用于绑定了两个域名的网站,将不带www的转向带www的

首先在空间设置里将index.php的优先级设为最高
然后编辑根目录下的index.php 替换为以下代码

1. 2. //-----------------------------------------------
3. //ad:www.wuliao5.com
4. //-----------------------------------------------
5. $jump301=1;//是否开启301跳转开关,1开 0关
6. $index_file='index.html';//首页文件 不支持SSI(shtml/shtm)
7.

8. if(substr($_SERVER['SERVER_NAME'],0,4)!='www.'&&$jump301)
9. {
10. header('HTTP/1.1 301 Moved Permanently');
11. header('Location:http://www.'.$_SERVER['SERVER_NAME']);
12. exit();
13. }
14.

15.

16.

17. if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
18. {
19. header('Location:install/index.php');
20. exit();
21. }
22. //自动生成HTML版
23. if(isset($_GET['upcache']))
24. {
25. require_once (dirname(__FILE__) . "/include/common.inc.php");
26. require_once DEDEINC."/arc.partview.class.php";
27. $GLOBALS['_arclistEnv'] = 'index';
28. $row = $dsql->GetOne(“Select * From `dede_homepageset`”);
29. $row['templet'] = MfTemplet($row['templet']);
30. $pv = new PartView();
31. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . “/” . $row['templet']);
32. $pv->SaveToHtml(dirname(__FILE__).’/’.$index_file);
33. include(dirname(__FILE__).’/’.$index_file);
34. exit();
35. }
36. include(dirname(__FILE__).’/’.$index_file);
37. ?>
38.

ok,大功告成,去查询工具查一下吧



收缩
  • 微信客服
  • 微信二维码
  • 电话咨询

  • 400-1100-266