1、PHP伪静态化页面的实现.txt成熟不是心变老,而是眼泪在眼里打转却还保持微笑。把一切平凡的事做好既不平凡,把一切简单的事做对既不简单。PHP伪静态化页面的实现2009/11/17 19:31方法一:一 打开 Apache 的配置文件 httpd.conf 。二 将#LoadModule rewrite_module modules/mod_rewrite前面的#去掉三 在 httpd.conf中添加:RewriteEngine On#RewriteCond %ENV:SCRIPT_URL (?:index|dispbbs)-0-9+.htmlRewriteRule (.*?(?:index|
2、dispbbs)-(-0-9+).html 1.php?_is_apache_rewrite=1&_rewrite_arg=2四 要实现asp帖子URL到php帖子的映射,在 第三步的和之间添加:RewriteMap tolowercase int:tolowerRewriteCond %QUERY_STRING (?:boardid|page|id|replyid|star|skin)=d+ NCRewriteRule (.*(?:index|dispbbs).asp 1.php?tolowercase:%QUERY_STRING&_is_apache_rewrite=1五 保存httpd.
3、conf并重启Apache。方法二:?php/*功能:PHP页面伪静态化具体用法:实现效果为:test.php/year/2006/action/_add.htmlmod_rewrite();$yearn=$_GETyear;/结果为2006$action=$_GETaction;/结果为_add*/function mod_rewrite()global $_GET;$nav=$_SERVERREQUEST_URI;$script_name=$_SERVERSCRIPT_NAME;$nav=substr(ereg_replace($script_name,urldecode($nav),1)
4、;$nav=preg_replace(/.ht(m)1(l)0,1$/,$nav);/这句是去掉尾部的.html或.htm$vars = explode(/,$nav);for($i=0;$iapache 伪静态设置方法一 打开 apache 的配置文件 httpd.conf二 将#loadmodule rewrite_module modules/mod_rewrite 前面的#去掉三 打开 httpd-vhosts.conf四 修改如下:Options FollowSymLinksServerAdmin DocumentRoot d:myphpsophiacnServerName Erro
5、rLog logs/-error_logCustomLog logs/-access_log commonphp_admin_value open_basedir d:myphpsophiacn;C:WINDOWSTEMPRewriteEngine onRewriteRule (.*)/list-(0-9+)-(0-9+).html$ $1/list.php?sort_id=$2&page=$3RewriteRule (.*)/article-(0-9+)-(0-9+).html$ $1/article.php?sort_id=$2&id=$3重启 apache.htaccess 方法:RewriteEngine OnRewriteBase /RewriteRule list-(0-9+)-(0-9+).html$ list.php?sort_id=$1&page=$2RewriteRule article-(0-9+)-(0-9+).html$ article.php?sort_id=$1&id=$2Referece http:/