Analysis on pathinfo mode and URL rewriting in ThinkPHP

Source: Internet
Author: User
The Chinese language has never been very good. I really don't know how to explain this pathinfo mode. let's talk about the pathinfo mode with a piece of code. The code is as follows:


Http: // serverName/appName/module/action/id/1/

This is the pathinfo mode.

Without considering routing, the first parameter will be parsed into a module name (if grouping is enabled, it will be rolled back in sequence), and the second parameter will be parsed into an operation, the following parameters are explicitly transmitted and must appear in pairs. for example:

The code is as follows:


Http: // serverName/appName/module/action/year/2008/month/09/day/21/

The URL usually contains index. php, in order to achieve better SEO effect, you may need to remove the index in the URL. php, which can be achieved through URL rewriting, usually requires the server to enable the URL_REWRITE module.
The configuration process of Apache is as follows:
1. the mod_rewrite.so module is loaded in the httpd. conf configuration file.
2. change AllowOverride None to All
3. make sure that URL_MODEL is set to 2.
4. Save the following content as a. htaccess file and put it under the same directory of the entry file

The code is as follows:



RewriteEngine on
RewriteCond % {REQUEST_FILENAME }! -D
RewriteCond % {REQUEST_FILENAME }! -F
RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]

Never touched again. the htacces file can be Baidu. here we will remind you that the saved file name is. htaccess, which may only look like a suffix. do not add a *** in front of it ***. htaccess.

After Apache is restarted, the original
Http: // serverName/index. php/Blog/read/id/1
You can access
Http: // serverName/Blog/read/id/1
Simplified URL

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.