PATHINFO mode optimization in ThinkPHP, thinkphppathinfo_PHP tutorial

Source: Internet
Author: User
ThinkPHP PATHINFO mode optimization, thinkphppathinfo. PATHINFO mode optimization in ThinkPHP, thinkphppathinfoThinkPHP3.1.2 Chapter 16.2 "hide index" in the official manual. hiding indexes in Ngnix is mentioned in php. SEO-friendly methods are implemented in php, including PATHINFO mode optimization in ThinkPHP and thinkphppathinfo
ThinkPHP 3.1.2 The Section 16.2 "hide index. php" in the official manual mentions hiding index. php in Ngnix to implement SEO-friendly methods. the following code is used: location/{if (! -E $ request_filename) {rewrite ^ (. *) $/index. php? S = $1 last; break ;}} this method has very poor performance, because it will also judge the existence of the image file, increasing the disk IO overhead, in the book Nginx HTTP Server, we mentioned an optimization method, that is, to change it to the following code. Location/{if ($ request_filename ~ *"\. (Gif | jpg | jpeg | png | swf | js | css) ") {break; // The image file is no longer rewritten or determined by the existence of the file, this prevents useless Nginx checks and reduces disk I/O overhead} if (! -E $ request_filename) {rewrite ^ (. *) $/index. php? S = $1 last; break ;}# simple to no technical content, but the effect is good ~


How is the pathinfo mode in thinkPHP implemented?

PATH_INFO is a CGI 1.1 environment variable
The pathinfo mode maps each section of the path to a preset variable.
That is, the meaning is determined by position, such as a subscript array.
$ _ SERVER ['path _ info'] this is a prototype

Then the regular expression or string function is used to obtain parameters.

Common thinkphp URL modes

Which one is used? it mainly depends on the seo requirements of the operation side and the support of your current server. to put it bluntly, the thinkphp URL request mode is for seo optimization, tp uses the pathinfo mode by default.

Technical support: in area 9th of this paper, major brings you a different technical experience!

In Section 16.2 "hide index. php" in the official manual for faster ThinkPHP 3.1.2, we mentioned how to hide index. php in Ngnix to implement SEO-friendly methods...

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.