网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站设计 > PHP
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 82.116.154.18
Old 2009-01-07, 11:42 AM
adsense adsense is offline
普通会员
 
Join Date: 2006-04-03
Posts: 44
adsense 正向着好的方向发展
Default Php伪静态写法附代码

比如这个网页
http://www.jb51.net/soft.php/1,100,8630.html
其实处理的脚本是soft.php 参数为1,100,8630
相当于soft.php?a=1&b=1=100&c=8630 只不过这样的URL太难记。搜索引擎也不喜欢。
真静态只是完全生成了HTML。
客户端访问的时候直接输出。不用脚本解释。在流量非常大的时候(比如每天有上百万的访问量的时候)会起到很好的效果。也就是说服务器端实实在在的存在这个HTML页面。
当然在你网站的流量没有那么大的时候。URL重写是最好的方法(个人观点,大流量的时候可以考虑负载均衡了。同样没有关系)
附URL重写的方法有很多种,APACHE,IISREWRITE。甚至PHP脚本都可以直接处理。比如上例中就是PHP脚本直接处理(该方法好处是大流量的时候直接减轻WEB伺服器的压力。PS:同样也是个人观点:
================================================
下面以程序为例讲一下PHP伪静态的程序实现方法,其实这方法我之前已经有在其它论坛社区发过
程序为例:
http://www.0058.net/soft.php/1,100,8630.html

Code:
<?php 
//利用server变量 取得PATH_INFO信息 该例中为 /1,100,8630.html 也就是执行脚本名后面的部分 
if(*$path_info =$_SERVER["PATH_INFO"]){ 
//正则匹配一下参数 
if(preg_match("/\/(\d+),(\d+),(\d+)\.html/si",$path_info,$arr_path)){ 
$gid =intval($arr_path[1]); //取得值 1 
$sid =intval($arr_path[2]); //取得值100 
$softid =intval($arr_path[3]); //取得值8630 
}else die("Path:Error!"); 
//相当于soft.php?gid=1&sid=100&softid=8630 
}else die('Path:Nothing!'); 
//就是这么简单了。~)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:07 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.