Implementation of PHP pseudo-static page

Source: Internet
Author: User
Tags vars

<?php
/*
功能:PHP伪静态化页面的实现
具体用法:
例如链接为:test.php/year/2006/action/_add.html
mod_rewrite();
 $yearn= $_GET["year"];//结果为'2006'
 $action= $_GET["action"];//结果为'_add'
Power By:cnwbshow.com
E-mail:cnwbshow.@gmail.com
网址:http://www.cnwbshow.com*/
function mod_rewrite(){
global  $_GET;
 $nav= $_SERVER["REQUEST_URI"];
 $script_name= $_SERVER["SCRIPT_NAME"];
 $nav=substr(ereg_replace("^ $script_name","",urldecode( $nav)),1);
 $nav=preg_replace("/^.ht(m){1}(l){0,1} $/","", $nav);//这句是去掉尾部的.html或.htm
 $vars = explode("/", $nav);
for( $i=0; $i<Count( $vars); $i+=2){
  $_GET[" $vars[ $i]"]= $vars[ $i+1];
}
return  $_GET;
}
>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.