Home > Backend Development > PHP Tutorial > Detailed explanation of thinkphp's four url access methods, thinkphpurl_PHP tutorial

Detailed explanation of thinkphp's four url access methods, thinkphpurl_PHP tutorial

WBOY
Release: 2016-07-13 10:12:47
Original
1059 people have browsed it

Detailed explanation of thinkphp’s four url access methods, thinkphpurl

This article analyzes four url access methods of thinkphp through examples. Share it with everyone for your reference. The specific analysis is as follows:

1. What is MVC

thinkphp’s MVC model is very flexible and can run even with only three and one.

M-Model writes model classes to operate on data

V -View writes html files and renders the page

C-Controller writes class file (UserAction.class.php)

2. MVC features of ThinkPHP (Easy understanding)

3. Directory corresponding to ThinkPHP’s MVC (Easy understanding)

M project directory/application directory/Lib/Model

V Project Directory/Application Directory/Tpl

C Project Directory/Application Directory/Lib/Action

4. URL access C (simple understanding)

5. 4 ways to access URL (This is the key point!!)

1.PATHINFO mode --The key point is used a lot later. If you want to pass multiple parameters, you can use the key 1/value 1/key 2/value 2 method

Copy code The code is as follows:
http://domain name/project name/entry file/module name/method name/key 1/value 1/ Key2/Value2

2. Normal mode is also called rewrite mode

Copy code The code is as follows:
http://domain name/project name/entry file?m=module name&a=method name& key1=value1&key2=value2

3.REWRITE rewriting mode, remove the entry file to facilitate SEO optimization

Copy code 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

Copy code The code is as follows:
http://domain name/project name/entry file?s=module name/method name/key 1/value1/key2/value2

How to modify / in the PATHINFO address to - in Home/Conf/config.php

Copy code The code is as follows:
'URL_PATHINFO_DEPR'=>'-',//Modify the delimiter of RUL and put the parameter part of the address bar /Replace with: http://domain name/project name/entry file/module name-method name-key 1-value 1-key 2-value 2

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

Copy code The code is as follows:
define('APP_DEBUG',ture);//If set to true, the file will not be cached, if false, the file will be cached

How to enable REWRITE mode

Look for rewrite_module modules/mod_rewrite.sl in httpd.conf, remove the # and restart the service. Create a new .htaccess.php under the entry file. Rewriting the file means removing index.php:

Copy code 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 be helpful to everyone’s ThinkPHP framework programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/919265.htmlTechArticleDetailed explanation of the four url access methods of thinkphp, thinkphpurl This article analyzes the four url access methods of thinkphp. Share it with everyone for your reference. The specific analysis is as follows: 1. What is MVC...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template