URL pseudo static PHP pseudo static code attached

Source: Internet
Author: User
Like this page.
Http://www.jb51.net/soft.php/1,100,8630.html
The script that is actually processed is the soft.php parameter of 1,100,8630
The equivalent of soft.php?a=1&b=1=100&c=8630 only such URLs are too difficult to remember. Search engines don't like it either.
True static just completely generates HTML.
Direct output when the client accesses it. No scripting explanation. It works well when traffic is very large, such as millions of visits per day. That is to say, the server side actually exists this HTML page.
Of course, the traffic on your site is not that big. URL rewriting is the best method (personal view, when large traffic can be considered load balanced.) also no relationship)
There are many ways to rewrite the URL, apache,iisrewrite. Even PHP scripts can be processed directly. For example, in the example above, the PHP script is processed directly (the advantage of this method is that it reduces the pressure of the Web server directly when the traffic is large.) PS: Also a personal point of view:
================================================
The following is a procedure for the example of PHP pseudo-static program implementation method, in fact, this method I have been in other forum community has been sent
Program for example:
Http://www.jb51.net/soft.php/1,100,8630.html

Copy the Code code as follows:


Use the server variable to get path_info information in this case,/1,100,8630.html is the part that executes the script name.
if (@ $path _info =$_server["Path_info"]) {
Regular match parameters
if (Preg_match ("/\/(\d+), (\d+), (\d+) \.html/si", $path _info, $arr _path)) {
$gid =intval ($arr _path[1]); Get value 1
$sid =intval ($arr _path[2]); Get Value 100
$softid =intval ($arr _path[3]); Get Value 8630
}else die ("path:error!");
Equivalent to soft.php?gid=1&sid=100&softid=8630
}else die (' path:nothing! ');
It's so simple. ~


The above describes the URL pseudo-static PHP pseudo-static code, including the URL pseudo-static content, I hope the PHP tutorial interested in a friend helpful.

  • 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.