thinkphp four kinds of URL access mode detailed _php instance

Source: Internet
Author: User
Tags php template smarty template

This article analyzes the four kinds of URL access methods of thinkphp. Share to everyone for your reference. The specific analysis is as follows:

One, what is MVC

Thinkphp's MVC pattern is very flexible, even if only three and one can run.

M-model write the Model class to manipulate the data

V-view Write HTML file, page rendering

C-controller Write class file (UserAction.class.php)

Ii. features of thinkphp MVC (Simple Understanding)

third, the thinkphp of the MVC corresponding directory (simple to understand)

M project directory/application directory/lib/model

V project directory/application directory/TPL

C project directory/application directory/lib/action

iv. URL Access C (easy to understand)

Five, 4 ways to access the URL (this is the key!!) )

1.PATHINFO Mode -focus on the following use very much, if you want to pass multiple parameters can use the key 1/value 1/Key 2/value 2 method

Copy Code code as follows:
http://domain name/project name/Entry file/Module name/method name/Key 1/value 1/Key 2/value 2

2. Normal mode is also known as rewrite mode

Copy Code code as follows:
http://domain name/project name/entry file? m= Module name &a= method name & key 1= value 1& key 2= value 2

3.REWRITE Rewrite mode , remove entry file for SEO optimization

Copy Code code as follows:
http://domain name/project name/Module name/method name/Key 1/value 1/Key 2/value 2

4. Compatibility mode

Copy Code code as follows:
http://domain name/project name/entry file? s= Module name/method name/Key 1/value 1/Key 2/value 2

How to modify/change in PathInfo address-in home/conf/config.php

Copy Code code as follows:
' Url_pathinfo_depr ' => '-',//Modify the Rul separator, put the Address bar parameter part/replace: http://domain name/project name/Entry file/Module name-method name-Key 1-Key value 2

Open Call mode in index.php in order to not allow file caching to affect development in the back-generation mode

Copy Code code as follows:
Define (' App_debug ', ture); If set to Ture do not cache files, false caches files

Rewrite mode opening method

Find Rewrite_module MODULES/MOD_REWRITE.SL in httpd.conf to remove the reboot service and create a new one under the entry file. htaccess.php, rewrite file is to remove the meaning of index.php:

Copy Code code as follows:
Rewriteengine on
Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]

More interested in thinkphp related content readers can view the site topics: "thinkphp Introductory Course", "thinkphp Template Operation Skills Summary", "thinkphp Common Methods Summary", "Smarty Template Introductory Course" and "PHP template technology Summary."

I hope this article will help you with the PHP program design based on thinkphp framework.

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.