Babyliss Pro Perfect Curl PHP friendly URL implementation (vomiting blood recommendation)

Source: Internet
Author: User
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.

  • Related Article

    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.