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.jb51.net/soft.php/1,100,8630.html
复制代码 代码如下:
//利用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!');
//就是这么简单了。~)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide
