Methods are three ways to achieve pseudo-static PHP pages to achieve three PHP pseudo-static pages

Three ways to achieve pseudo-static pages PHP

 

PHP pseudo-static written - one

Also known as pseudo-static: URL Rewrite 

Mainly for SEO and students. (What SEO is? Do not ask me this. Oh ~ do not understand the network of SEO it ~ ~ ~ ~)

method one:

For example, this page

/soft.php/1,100,8630.html

In fact, the script deals with soft.php parameters 1,100,8630

Equivalent soft.php? A = 1 & b = 1 = 100 & c = 8630 but this URL too hard to remember. Search engines do not like.

Really just completely static generated HTML.

When clients access directly output. No script interpreter. In very large flow of time (for example, every day millions of visits when) will play a very good effect. This means that there is a real HTML pages on the server side.

Of course, not so much time in traffic to your site. URL rewriting is the best way (personal point of view, large flow can be considered when the load balancing. The same does not matter)

Methods attached URL rewriting There are many, APACHE, IISREWRITE. Even PHP scripts can be processed directly. For example, the above example is a PHP script to deal directly (which is a large advantage when flow rate WEB server directly alleviate pressure .PS: also a personal point of view:

================================================

The following program as an example to talk about PHP pseudo-static implementation of the program, in fact, this method has been made in other forums community before I

Program, for example:

/soft.php/1,100,8630.html

CODE:

// using the server variable PATH_INFO to obtain information about the case is /1,100,8630.html is part of the script execution behind the name

if(@$path_info =$_SERVER["PATH_INFO"]){

// regular match following 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 soft.php? Gid = 1 & sid = 100 & softid = 8630


// it is so simple. ~)

Method Two:

Opened the Apache configuration file httpd.conf.

The foregoing two #LoadModule rewrite_module modules / mod_rewrite # removed

Three in httpd.conf added:

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+).html 1.php?__is_apache_rewrite=1&__rewrite_arg=2
</IfModule>

Fourth, we must realize asp php posts to post URL mapping, the third step is added between the <IfModule mod_rewrite.c> and </ IfModule>:

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

Five save httpd.conf and restart Apache

Method three:

? <PHP
/ *
Function: PHP pseudo-static pages
specific use:
for example, the link is: test.php / year / 2006 / Action / _add.html
mod_rewrite ();
$ Yearn = $ _ GET [ "year"]; / / result is '2006'
$ $ _ the GET Action = [ "Action"]; // 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);//这句是去掉尾部的.html或.htm
$vars = explode("/",$nav);
for($i=0;$i<Count($vars);$i+=2){
$_GET["$vars[$i]"]=$vars[$i+1];
}
return $_GET;
}
mod_rewrite();
$yearn=$_GET["year"];//结果为'2006'
$action=$_GET["action"];//结果为'_add'
echo $yearn;
echo $action;
?>

? <PHP
/ *
Function: PHP pseudo-static pages
specific use:
for example, the link is: test.php / year / 2006 / Action / _add.html
mod_rewrite ();
$ Yearn = $ _ GET [ "year"]; / / result is '2006'
$ $ _ the GET Action = [ "Action"]; // 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);//这句是去掉尾部的.html或.htm
$vars = explode("/",$nav);
for($i=0;$i<Count($vars);$i+=2){
$_GET["$vars[$i]"]=$vars[$i+1];
}
return $_GET;
}
mod_rewrite();
$yearn=$_GET["year"];//结果为'2006'
$action=$_GET["action"];//结果为'_add'
echo $yearn;
echo $action;
?>

PHP pseudo-static written - one

Also known as pseudo-static: URL Rewrite 

Mainly for SEO and students. (What SEO is? Do not ask me this. Oh ~ do not understand the network of SEO it ~ ~ ~ ~)

method one:

For example, this page

/soft.php/1,100,8630.html

In fact, the script deals with soft.php parameters 1,100,8630

Equivalent soft.php? A = 1 & b = 1 = 100 & c = 8630 but this URL too hard to remember. Search engines do not like.

Really just completely static generated HTML.

When clients access directly output. No script interpreter. In very large flow of time (for example, every day millions of visits when) will play a very good effect. This means that there is a real HTML pages on the server side.

Of course, not so much time in traffic to your site. URL rewriting is the best way (personal point of view, large flow can be considered when the load balancing. The same does not matter)

Methods attached URL rewriting There are many, APACHE, IISREWRITE. Even PHP scripts can be processed directly. For example, the above example is a PHP script to deal directly (which is a large advantage when flow rate WEB server directly alleviate pressure .PS: also a personal point of view:

================================================

The following program as an example to talk about PHP pseudo-static implementation of the program, in fact, this method has been made in other forums community before I

Program, for example:

/soft.php/1,100,8630.html

CODE:

// using the server variable PATH_INFO to obtain information about the case is /1,100,8630.html is part of the script execution behind the name

if(@$path_info =$_SERVER["PATH_INFO"]){

// regular match following 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 soft.php? Gid = 1 & sid = 100 & softid = 8630


// it is so simple. ~)

Method Two:

Opened the Apache configuration file httpd.conf.

The foregoing two #LoadModule rewrite_module modules / mod_rewrite # removed

Three in httpd.conf added:

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+).html 1.php?__is_apache_rewrite=1&__rewrite_arg=2
</IfModule>

Fourth, we must realize asp php posts to post URL mapping, the third step is added between the <IfModule mod_rewrite.c> and </ IfModule>:

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

Five save httpd.conf and restart Apache

Method three:

? <PHP
/ *
Function: PHP pseudo-static pages
specific use:
for example, the link is: test.php / year / 2006 / Action / _add.html
mod_rewrite ();
$ Yearn = $ _ GET [ "year"]; / / result is '2006'
$ $ _ the GET Action = [ "Action"]; // 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);//这句是去掉尾部的.html或.htm
$vars = explode("/",$nav);
for($i=0;$i<Count($vars);$i+=2){
$_GET["$vars[$i]"]=$vars[$i+1];
}
return $_GET;
}
mod_rewrite();
$yearn=$_GET["year"];//结果为'2006'
$action=$_GET["action"];//结果为'_add'
echo $yearn;
echo $action;
?>

? <PHP
/ *
Function: PHP pseudo-static pages
specific use:
for example, the link is: test.php / year / 2006 / Action / _add.html
mod_rewrite ();
$ Yearn = $ _ GET [ "year"]; / / result is '2006'
$ $ _ the GET Action = [ "Action"]; // 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);//这句是去掉尾部的.html或.htm
$vars = explode("/",$nav);
for($i=0;$i<Count($vars);$i+=2){
$_GET["$vars[$i]"]=$vars[$i+1];
}
return $_GET;
}
mod_rewrite();
$yearn=$_GET["year"];//结果为'2006'
$action=$_GET["action"];//结果为'_add'
echo $yearn;
echo $action;
?>

Guess you like

Origin www.cnblogs.com/herocan/p/11366857.html