    
- 帖子
- 3852
- 积分
- 13044
- 威望
- 16780
- 金钱
- 36761
- 在线时间
- 1139 小时
         
|
网上有很多人问我怎么真正给discuz论坛301永久定向,那我就在这里详细说下我是怎么做discuz的301的。。。
首先需要建了名为301.inc.php的文件,复制粘贴以下代码
注意将www.3ast.com.cn换成www.3ast.com--------------------------------------------------------------------------- <?php
- $the_host = $_SERVER['HTTP_HOST']; //取得当前访问域名
- $url = $_SERVER['PHP_SELF']; //获取域名后的字串,如:/bbs/index.php
- $filename= substr( $url , strrpos($url , '/')+1 ); //提取当前文件名
- $querystring = $_SERVER["QUERY_STRING"]; //获取问号后面的参数
- if ($the_host !== 'www.3ast.com.cn') //验证当前访问域名:若非引号内的域名则进行如下跳转——
- {
- if ($querystring !== '') //验证文件名后是否有参数,如果有参数则跳转到——
- {
- header('HTTP/1.1 301 Moved Permanently'); //发出301头部,表明永久重定向
- header('Location: http://www.3ast.com/'.$filename.'?'.$querystring); //跳转到我的新域名地址【带参数】
- }
- else //如果无参数则跳转到——
- {
- header('HTTP/1.1 301 Moved Permanently'); //发出301头部,表明永久重定向
- header('Location: http://www.3ast.com/'.$filename); //跳转到我的新域名地址【不带参数】
- }
- }
- ?>
复制代码 --------------------------------------------------------------------------
--------------------------------------------------------------------------
然后到论坛跟目录下拷出7个文件,分别是
index.php
forumdisplay.php
viewthread.php
redirect.php
tag.php
logging.php
space.php
分别在以上文件的<?php 下面加入代码 include("301.inc.php");
Ok 收工 |
|