zoukankan      html  css  js  c++  java
  • 论坛结构改动,URL重写不影响收录地址的访问代码

    关于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");
  • 相关阅读:
    https authorization basic
    第二十一章 单例模式
    第十九章 组合模式
    第十八章 备忘录模式
    第十七章 适配器模式
    第十六章 状态模式
    新博客~
    CF922D Robot Vacuum Cleaner
    BZOJ1767 [CEOI2009]harbingers
    树的直径学习笔记
  • 原文地址:https://www.cnblogs.com/zerogo/p/2209248.html
Copyright © 2011-2022 走看看