thinkphp四种url访问方式详解
这篇文章主要介绍了thinkphp四种url访问方式,简单分析了ThinkPHPmvc相关概念并重点讲述了URL的四种访问方式,具有一定的参考借鉴价值,需要的朋友可以参考下
本文实例分析了thinkphp的四种url访问方式。分享给大家供大家参考。具体分析如下:
一、什么是MVC
thinkphp的MVC模式非常灵活,即使只有三个中和一个也可以运行。
M -Model 编写model类 对数据进行操作
V -View 编写html文件,,页面呈现
C -Controller 编写类文件(UserAction.class.php)
二、ThinkPHP的MVC特点 (简单了解)
三、ThinkPHP的MVC对应的目录 (简单了解)
M 项目目录/应用目录/Lib/Model
V 项目目录/应用目录/Tpl
C 项目目录/应用目录/Lib/Action
四、url访问C (简单了解)
五、url的4种访问方式 (这是重点!!)
1.PATHINFO 模式 --重点 在后面使用非常多,如果想传多个参数可以使用键1/值1/键2/值2方法
复制代码 代码如下:
域名/项目名/入口文件/模块名/方法名/键1/值1/键2/值2
2.普通模式也称为重写模式
复制代码 代码如下:
域名/项目名/入口文件?m=模块名&a=方法名&键1=值1&键2=值2
3.REWRITE重写模式,去掉入口文件便于SEO优化
复制代码 代码如下:
域名/项目名/模块名/方法名/键1/值1/键2/值2
4.兼容模式
复制代码 代码如下:
域名/项目名/入口文件?s=模块名/方法名/键1/值1/键2/值2
如何修改PATHINFO地址中的/改成-在Home/Conf/config.php中
复制代码 代码如下:
'URL_PATHINFO_DEPR'=>'-',//修改RUL的分隔符,把地址栏的参数部分/换成:域名/项目名/入口文件/模块名-方法名-键1-值1-键2-值2
在index.php中开启调用模式,为了在后产模式中不让文件缓存影响开发
复制代码 代码如下:
define('APP_DEBUG',ture);//如果设置为ture不缓存文件,false则缓存文件
REWRITE模式开启方法
在httpd.conf中查找rewrite_module modules/mod_rewrite.sl 把#去掉重启服务,在入口文件下新建.htaccess.php,重写文件是去掉index.php的意思:
复制代码 代码如下:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

The reason for the error is NameResolutionError(self.host,self,e)frome, which is an exception type in the urllib3 library. The reason for this error is that DNS resolution failed, that is, the host name or IP address attempted to be resolved cannot be found. This may be caused by the entered URL address being incorrect or the DNS server being temporarily unavailable. How to solve this error There may be several ways to solve this error: Check whether the entered URL address is correct and make sure it is accessible Make sure the DNS server is available, you can try using the "ping" command on the command line to test whether the DNS server is available Try accessing the website using the IP address instead of the hostname if behind a proxy

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

Differences: 1. Different definitions, url is a uniform resource locator, and html is a hypertext markup language; 2. There can be many urls in an html, but only one html page can exist in a url; 3. html refers to is a web page, and url refers to the website address.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

How to solve the problem that Tomcat cannot successfully access the war package after deploying it requires specific code examples. As a widely used Java Web server, Tomcat allows developers to package their own developed Web applications into war files for deployment. However, sometimes we may encounter the problem of being unable to successfully access the war package after deploying it. This may be caused by incorrect configuration or other reasons. In this article, we'll provide some concrete code examples that address this dilemma. 1. Check Tomcat service
