基于php伪静态的实现详细介绍 |
本文标签:php伪静态 1.根据$_SERVER[PATH_INFO]来操作实现 。 复制代码 代码如下: index.php $conn=mysql_connect("localhost","root","root")or dir("连接失败"); show_new.php页面 复制代码 代码如下: show_new.php header("Content-type:text/html;charset=utf-8"); 看到上面的这个我想大家肯定懂了吧 其实这种方式用的不多的下面的给大家说第二种方法了啊 2.根据配置.htaccess来实现 。 复制代码 代码如下: <IfModule rewrite_module> #写你的rewrite规则 RewriteEngine On # 可以配置多个规则,匹配的顺序是从上到下 RewriteRule one_new-id-(\d+)\.shtml$ one_new.php?id=$1 //这里的$1 代表的是第一个参数啊 RewriteRule abc_id(\d+)\.html$ error.php #设置404错误 #ErrorDocument 404 /error.php </IfModule> 你在one_new.php 页面echo $_GET[id] 肯定会输出 id的值了 说明:这个目前个人能力只能写到这里了 我以后会逐渐完善 的 |