Thinkphp: four url access methods. thinkphpurl_PHP tutorial

Source: Internet
Author: User
Thinkphp: thinkphpurl. Thinkphp provides a detailed description of the four url access methods. thinkphpurl This article analyzes the four url access methods of thinkphp. Share it with you for your reference. The specific analysis is as follows: 1. what are the four url access methods of MVC thinkphp? thinkphpurl

This article analyzes thinkphp's four url access methods. Share it with you for your reference. The specific analysis is as follows:

1. what is MVC?

Thinkphp's MVC mode is very flexible, and can be run even if only three or one of them.

M-Model write model class to operate data

V-View: compile html files and display pages

C-Controller: write a class file (UserAction. class. php)

II. MVC features of ThinkPHP(Easy to understand)

III. Directory corresponding to ThinkPHP MVC(Easy 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)

5. four url access methods(This is the key !!)

1. PATHINFO mode-- A lot of emphasis is placed on subsequent use. if you want to pass multiple parameters, you can use the key 1/value 1/Key 2/value 2 method.

The code is as follows:

Http: // domain name/project name/entry file/module name/method name/key 1/value 1/Key 2/value 2

2. the normal mode is also called the rewrite mode.

The code is 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 modeRemoves the entry file to facilitate SEO optimization.

The code is as follows:

Http: // domain name/project name/module name/method name/key 1/value 1/Key 2/value 2

4. compatibility mode

The code is 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/in the PATHINFO address-in Home/Conf/config. php

The code is as follows:

'URL _ PATHINFO_DEPR '=>'-', // modify the RUL separator, and change the parameter part of the address bar/To: http: // domain name/project name/entry file/module name-method name-key 1-value 1-key 2-value 2

Enable the call mode in index. php to prevent file caching from affecting development in post-production mode

The code is as follows:

Define ('app _ debug', ture); // if it is set to true, files are cached if false.

Method for enabling REWRITE mode

Find rewrite_module modules/mod_rewrite.sl in httpd. conf and remove # From the restart service. Create. htaccess. php in the entry file. rewrite the file to remove index. php:

The code is as follows:

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

I hope this article will help you with ThinkPHP framework programming.

In this article, we analyze thinkphp's four url access methods. Share it with you for your reference. The specific analysis is as follows: 1. what is MVC...

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.