Implementation of friendly URLs (recommended for vomiting)
You often see other stations of the URL is this it?
Http://www.xxx.com/module/show/action/list/page/7
Or
Http://xx.com/module/show/action/show/id/8.shtml with a name extension
Or
http://xx.com/module/show/action/show/id/8?word=ss&age=11
That's it.
Today I'm going to announce the implementation of this method and make the simplest code independent
Functions as follows, not encapsulated into classes, mainly not necessary, with the function can be more convenient
Copy the Code code as follows:
!--? php /**
* Get friendly URL Access
*
* @access public
* @return Array
*/
Function Getqueryst Ring () {
$_sgets = explode ("/", substr ($_server[' path_info '],1));
$_slen = count ($_sgets);
$_sget = $_get;
for ($i =0; $i <$_SLEN; $i +=2) {
if (!empty ($_sgets[$i]) &&!empty ($_sgets[$i +1]) $_sget[$_sgets[$i]] =$_sgets[$i +1];
}
$_sget[' m '] =!empty ($_sget[' m ']) && is_string ($_sget[' m ']) trim ($_sget[' m ']). ' Action ': ' Indexaction ';
$_sget[' a '] =!empty ($_sget[' a ')) && is_string ($_sget[' a ']) trim ($_sget[' a ']): ' Run ';
return $_sget;
}
/**
* Generate link URL
*
* @access public
* @param array $arr
* @return String
*/
function SE Turl ($arr) {
Global $Global;
$queryString = ';
if ($Global [' Urlmode ']==2) {
foreach ($arr as $k = = $v) {
$queryString. = $k. '/'. $v. '/';
}
}
$queryString. = $Global [' Urlsuffix '];
return $queryString;
}
?>
Very simple to use
Copy the Code code as follows:
$_get= getquerystring ();
?>
But it's not going to work, so it's only possible
Http://www.xxx.com/index.php/module/show/action/list/page/7 like this.
There's a index.php in the middle, so we're going to get rid of him and rewrite
But some files do not want this, such as the style picture, then put in conditions
Create a. htaccess file
Copy the Code code as follows:
Rewriteengine on
Rewritecond $!^ (index\.php|css|pics|themes|js|robots\.txt)
Rewriterule ^ (. *) $ index.php/$1 [L]
It's OK now, let's go test it.
Copy the Code code as follows:
$_get= getquerystring ();
Print_r ($_get);
?>
The above describes the implementation of the Babyliss Pro Perfect curl PHP friendly URL (recommended for vomiting), including the Babyliss Pro Perfect curl content, and hope to be interested in the PHP tutorial friends helpful.