论坛结构改动,URL重写不影响收录地址的访问代码
2008-11-30 20:46
239 查看
关于URL重写,可能有站长需要发下,好查询。
首先需要做的事三个文件,
index.php
read.php
thread.php
做这三个文件放在原来的目录就可以了。
第一种方法有演示。
以下代码能仅把BBS目录移入根目录,
比如吧 http://liulangmao.com/bbs/read.php?tid=16194 重写为http://liulangmao.com/read.php?tid=16194
Copy code
<?php
$a=$_SERVER['URL'];
$a=substr($a,4);
header("location:$a");
?>
以下代码能实现目录为www开头域名重写为bbs开头,并把bbs目录移动到根目录,
比如吧 http://www.liulangmao.com/bbs/read.php?tid=16194 重写为http://bbs.liulangmao.com/read.php?tid=16194
Copy code
<?php
require_once('global.php');
$a=$_SERVER['URL'];
$a=substr($a,4);
$b=$db_bbsurl;
$url = str_replace("www", "bbs", "$b");
//echo $url;
$url=substr($url, 0,-4);
$c=$url.$a;
header("location:$c");
?>
补充一种,同目录下的域名重写。【不推荐使用,百度搜索会当此为作弊】
现在要用的URL地址:http://liulangmao.com
换之前用的URL域名:http://www.liulangmao.com
Copy code
<?php
require_once('global.php');
$url = "http://liulangmao.com".$_SERVER['REQUEST_URI'];
if ($db_bbsurl!="http://www.liulangmao.com")Header("Location:$url");
首先需要做的事三个文件,
index.php
read.php
thread.php
做这三个文件放在原来的目录就可以了。
第一种方法有演示。
以下代码能仅把BBS目录移入根目录,
比如吧 http://liulangmao.com/bbs/read.php?tid=16194 重写为http://liulangmao.com/read.php?tid=16194
Copy code
<?php
$a=$_SERVER['URL'];
$a=substr($a,4);
header("location:$a");
?>
以下代码能实现目录为www开头域名重写为bbs开头,并把bbs目录移动到根目录,
比如吧 http://www.liulangmao.com/bbs/read.php?tid=16194 重写为http://bbs.liulangmao.com/read.php?tid=16194
Copy code
<?php
require_once('global.php');
$a=$_SERVER['URL'];
$a=substr($a,4);
$b=$db_bbsurl;
$url = str_replace("www", "bbs", "$b");
//echo $url;
$url=substr($url, 0,-4);
$c=$url.$a;
header("location:$c");
?>
补充一种,同目录下的域名重写。【不推荐使用,百度搜索会当此为作弊】
现在要用的URL地址:http://liulangmao.com
换之前用的URL域名:http://www.liulangmao.com
Copy code
<?php
require_once('global.php');
$url = "http://liulangmao.com".$_SERVER['REQUEST_URI'];
if ($db_bbsurl!="http://www.liulangmao.com")Header("Location:$url");
相关文章推荐
- 论坛结构改动,URL重写不影响收录地址的访问代码
- 论坛结构改动,URL重写不影响收录地址的访问代码
- 论坛结构改动,URL重写不影响收录地址的访问代码
- React Native Android 代码中设置访问js 的地址
- C语言计算一个结构体内成员地址的偏移量的两种方法(代码实例)
- hibernate版本改动对配置、代码影响
- 一段不太好的代码:IE主页不是本站地址就不充许访问或下载
- 数据访问代码如何影响数据库性能
- 实例代码(栈地址增长方向、vtable对类size的影响、对象最小size概念、结构体对齐规则(对齐参数)、sizeof(指针),free与delete的区别)
- L型代码结构案例:Link访问权限(上)
- drv experiment : 从内核API代码定位函数地址或结构指针地址
- 手机访问网页地址跳转手机站代码
- ASP.NET纯代码实现伪静态地址(URL重写)
- EntLib.com Forum / YAF 开源论坛--源码的目录结构(对分析代码很有帮助)
- 嵌入式系统经常具有要求程序员去访问某特定的内存位置的特点。在某工程中,要求设置一绝对地址为0x67a9的整型变量的值为0xaa66。编译器是一个纯粹的ANSI编译器。写代码去完成这一任务。
- 关于百度收录,加入联盟不会影响收录,投放广告代码也不影响
- 9月8日国盟CISA每日一题 以下哪一种攻击最有可能影响网络资源的可用性? A.中间人 B.拒绝服务DOS C.网络钓鱼 D.结构化查询语言SQL注入 论坛讨论地址:http://www.cncisa
- L型代码结构案例:Link访问权限(上)
- Discuz!教程之论坛开启了版块子域名绑定,如果避免多域名访问帖子和重复收录
- 盛悦论坛打不开,盛悦论坛挂了,盛悦论坛被黑,请使用这个地址访问即可访问