Introduction: This is a detailed page of three methods to implement PHP pseudo-static pages. It introduces PHP, PHP, HTML, URL, knowledge, skills, experience, and some PHP Source Code related to the three methods used to implement PHP pseudo-static pages.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 347703 'rolling = 'no'>
PHP pseudo-static writing-one
Pseudo static name: URL rewriting
Mainly for Seo. (What is Seo? You don't have to ask me this. Haha ~ If you do not understand Seo, then ~~~~)
Method 1:
For example, this webpage
Http://www.2cto.com/soft. php/1,100,8630.html
In fact, the soft. php parameter is 1,100,863 0.
Equivalent to soft. php? A = 1 & B = 1 = 100 & C = 8630, but such a URL is too hard to remember. Search engines do not like it either.
Real static only completely generates HTML.
Output directly when accessing the client. No script explanation is required. When the traffic is very large (for example, when there are millions of visits each day), it will play a very good effect. That is to say, the server actually has this HTML page.
Of course, when the traffic on your website is not that large. URL rewriting is the best method (in my opinion, Server Load balancer can be considered when the traffic is high. It also does not matter)
There are many URL rewriting methods, such as Apache and iisrewrite. Even PHP scripts can be processed directly. For example, in the above example, PHP scripts are directly processed (the advantage of this method is to directly reduce the pressure on the Web server when the traffic is high. PS: also personal opinion:
========================================================== ==========
The following usesProgramFor example, I will introduce the PHP pseudo-static program implementation method. In fact, this method has already been used in other forums.CommunitySent
Program example:
Http://www.2cto.com/soft. php/1,100,8630.html
Code:
// Use the server variable to obtain the path_info information. In this example, It is/, 8630.html, that is, the part after the execution Script Name.
If (@ $ path_info = $ _ server ["path_info"]) {
// Regular Expression Matching 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
// It's that simple .~)
Method 2:
1. Open the configuration file httpd. conf of Apache.
2. Remove the # loadmodule rewrite_module modules/mod_rewrite before #.
3. Add the following in httpd. conf:
<Ifmodule mod_rewrite.c>
Rewriteengine on
# Rewritecond % {env: script_url }(? : Index | dispbbs00000000-0-900000000.html
Rewriterule ^ (.*? (? : Index | dispbbs00000000-(-0-9000000000000.html 1.php? _ Is_apache_rewrite = 1 & __ rewrite_arg = 2
</Ifmodule>
4. To map ASP post URLs to PhP posts, add the following between <ifmodule mod_rewrite.c> and </ifmodule> in step 3:
Rewritemap tolowercase INT: tolower
Rewritecond % {QUERY_STRING }(? : Boardid | PAGE | ID | replyid | star | skin) = d + [Nc]
Rewriterule ^ (.*(? : Index | dispbbs). asp 1.php? {Tolowercase: % {QUERY_STRING }}&__ is_apache_rewrite = 1
5. Save httpd. conf and restart Apache
Method 3:
/*
function: PhP pseudo-static page implementation
usage:
for example, the link is test. PHP/year/2006/Action/_add.html
mod_rewrite ();
$ yearn = $ _ Get ["year"]; // The result is '000000'
$ action = $ _ Get ["action"]; // The result is '_ add'
*/
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 ); // The end of this sentence is .htmlor .htm
$ vars = explode ("/", $ NAV);
for ($ I = 0; $ I $ _ Get ["$ vars [$ I]"] = $ Vars [$ I + 1];
}< br>
return $ _ Get;
}< br>
mod_rewrite ();
$ yearn =$ _ Get ["year"]; // The result is '000000'
$ action = $ _ Get ["action"]; // The result is '_ add'
echo $ yearn;
echo $ action;
?>
/*
function: PhP pseudo-static page implementation
usage:
for example, the link is test. PHP/year/2006/Action/_add.html
mod_rewrite ();
$ yearn = $ _ Get ["year"]; // The result is '000000'
$ action = $ _ Get ["action"]; // The result is '_ add'
*/
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 ); // The end of this sentence is .htmlor .htm
$ vars = explode ("/", $ NAV);
for ($ I = 0; $ I $ _ Get ["$ vars [$ I]"] = $ Vars [$ I + 1];
}< br>
return $ _ Get;
}< br>
mod_rewrite ();
$ yearn =$ _ Get ["year"]; // The result is '000000'
$ action = $ _ Get ["action"]; // The result is '_ add'
echo $ yearn;
echo $ action;
?>
This method is the most direct !~~~ Haha... the water and wood for you to provide...
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/347703.html pageno: 3