PathInfo mode and URL rewriting in thinkphp

Source: Internet
Author: User
Do not know how to explain this pathinfo mode, then first a piece of code, say PathInfo mode bar

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

This is PathInfo mode .

Without regard to routing, the first parameter is parsed into the module name (if grouping is enabled, then recursively), the second parameter is parsed into an operation, the subsequent arguments are passed explicitly, and must appear in pairs, for example:

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

The usual URL contains index.php, in order to achieve a better SEO effect may need to remove the URL inside the index.php, through the way of URL rewriting can achieve this effect, usually need to open the Server Url_rewrite module to support.

The following is the Apache configuration process, you can refer to the following:

1. The mod_rewrite.so module is loaded in the httpd.conf configuration file

2. AllowOverride None Change None to all

3. Make sure the Url_model is set to 2

4. Save the following content as a. htaccess file in a sibling directory of the portal file

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

I haven't had any contact with you. htacces file can be Baidu some, here to remind you, save the file name is. htaccess, may seem to 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

Simplified URL address

  • 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.