Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the url access methods of ThinkPHP

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the relevant knowledge of ThinkPHP's url access method, the content is detailed and easy to understand, the operation is simple and fast, and it has certain reference value. I believe you will gain something after reading this ThinkPHP url access method. Let's take a look at it.

What is MVC

Thinkphp's MVC mode is so flexible that it works even if there are only three neutralizations.

M-Model writes model classes to manipulate data.

V-View writes html files and pages are rendered

C-Controller to write class files (UserAction.class.php)

Second, the MVC characteristics of ThinkPHP (simple understanding)

3. The directory corresponding to the MVC of ThinkPHP (simple understanding)

M project directory / application directory / Lib/Model

V project directory / application directory / Tpl

C project directory / application directory / Lib/Action

4. Url visits C (simple understanding)

5. 4 ways to access url (this is the key point! )

1.PATHINFO mode-the emphasis 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.

The code is as follows:

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

two。 Normal mode is also known as rewriting 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 rewrite mode, remove 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 / change the PATHINFO address to-in Home/Conf/config.php

The code is as follows:

'URL_PATHINFO_DEPR'= >' -', / / modify the delimiter of RUL and replace the parameter part of the address bar with: http:// domain name / project name / entry file / module name-method name-key 1-value 1-key 2-value 2

Open the invocation mode in index.php in order not to let file caching affect development in post-production mode

The code is as follows:

Define ('APP_DEBUG',ture); / / if ture is set to not cache files, false caches files

REWRITE mode opening method

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

The code is as follows:

RewriteEngine on RewriteCond% {REQUEST_FILENAME}!-d RewriteCond% {REQUEST_FILENAME}!-f RewriteRule ^ (. *) $index.php/$1 [QSA,PT,L] this is the end of the article on "what are the url access methods for ThinkPHP?" Thank you for reading! I believe you all have a certain understanding of "what are the url access methods of ThinkPHP". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report