A brief analysis of pathinfo pattern and URL rewriting _php techniques in thinkphp

Source: Internet
Author: User

Copy Code code as follows:

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

This is PathInfo mode.

Without considering routing, the first parameter is resolved to the module name (if grouping is enabled, then recursion backwards), the second parameter is parsed into action, the subsequent argument is explicitly passed, and must be in pairs, for example:

Copy Code code as follows:

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

The usual URL contains index.php, in order to achieve better SEO effect may need to remove the URL inside the index.php, through the way of URL rewriting can achieve this effect, usually requires the server to open Url_rewrite module to support.
Here is the Apache configuration process, you can refer to the following:
1, httpd.conf configuration file loaded with mod_rewrite.so module
2, allowoverride none change none to all
3, make sure Url_model set to 2
4. Save the following content as a. htaccess file in the same sibling directory as the entry file

Copy Code code as follows:

<ifmodule mod_rewrite.c>
Rewriteengine on
Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
</IfModule>

For the beginning has not been contacted. htacces file can be a few Baidu, here to remind you, save the filename is. htaccess, may seem to have only suffix, that is, do not add a ***.htaccess in front.

After restarting Apache, the original
Http://serverName/index.php/Blog/read/id/1
You can access it by accessing
Http://serverName/Blog/read/id/1
simplifies the URL address

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.