Home > Backend Development > PHP Tutorial > URL pseudo-static PHP pseudo-static writing method with code

URL pseudo-static PHP pseudo-static writing method with code

WBOY
Release: 2016-07-29 08:38:16
Original
942 people have browsed it

For example, this webpage
http://www.jb51.net/soft.php/1,100,8630.html
In fact, the script processed is soft.php and the parameter is 1,100,8630
It is equivalent to soft.php?a=1&b=1= 100&c=8630 But such a URL is too difficult to remember. Search engines don’t like it either.
True static is just fully generated HTML.
Output directly when the client accesses. No need for script explanation. It will have very good results when the traffic is very large (such as when there are millions of visits every day). In other words, this HTML page actually exists on the server side.
Of course when the traffic of your website is not that big. URL rewriting is the best method (in my personal opinion, you can consider load balancing when there is large traffic. It doesn't matter either)
There are many methods of URL rewriting, including APACHE and IISREWRITE. Even PHP scripts can handle it directly. For example, in the above example, it is processed directly by PHP script (the advantage of this method is that it directly reduces the pressure on the WEB server when there is a large amount of traffic. PS: This is also a personal opinion:
================== ================================
Let’s take the program as an example to talk about the PHP pseudo-static program implementation method. In fact, this I have already posted the method in other forums and communities before. Take the program as an example:
http://www.jb51.net/soft.php/1,100,8630.html

Copy the code The code is as follows:

//Use the server variable to obtain the PATH_INFO information. In this example, it is /1,100,8630.html, which is the part after the execution script name.
if(@$path_info =$_SERVER["PATH_INFO"]){
// Regularly match the parameters
if(preg_match("//(d+),(d+),(d+).html/si",$path_info,$arr_path)){
$gid =intval($arr_path[1]); //Get the value 1
$sid =intval($arr_path[2]); //Get the value 100
$softid =intval($arr_path[3]); //Get the value 8630
}else die("Path:Error !");
//Equivalent to soft.php?gid=1&sid=100&softid=8630
}else die('Path:Nothing!');
//It’s that simple.~)


The above introduces the url pseudo-static PHP pseudo-static writing method and the code, including the url pseudo-static content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template