ThinkPHP学习笔记(一)ThinkPHP部署
作者:hebedich 时间:2023-09-09 12:42:16
已经下载了wampserver,以后有时间试下在本地运行ThinkPHP。
在app/lib/Action/文件夹下可以为每一个模块定义控制器类,一个模块可以包含多个操作方法,当有请求的时候,会从URL参数中解析当前请求的模块和操作。比如定义的默认控制器类IndexAciton.class.php:
<?php
class IndexAction extends Action{
ptotect function _initialize(){
header("Content-Type:text/html;charset=utf-8");
}
public function index(){
$this->display();
}
public function imit(){
echo "<h2>Sae服务模拟器功能测试(以下服务在本地也可以运行):</h2>";
}
}
访问http://localhost/,系统会访问默认的模块(Index)的默认操作(index)。相对的输入http://localhost/Index/imit,系统就会访问默认的模块(Index)的操作方法(imit)。这种URL模式是PATHINFO模式,ThinkPHP的默认格式,还可以在ThinkPHP/Conf/convention.php里设置其他格式,如普通模式、REWRITE模式和兼容模式。
只是笔记,为什么不能设置为仅自己可见呢,我写的乱七八糟都不好意思给人看啊。
URL请求的REWRITE模式,是在PATHINFO模式的基础上添加重写规则的支持,Apache的话,是在入口文件同级处添加.htaccess文件,内容是:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
只有这样是不行的,还需要开启Apache的rewrite功能。在httpd.conf配置文件中找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#,找到AllowOverride None改为AllowOverride All。如此才有效。
标签:ThinkPHP,部署
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
IA学习笔记04:标签系统
2009-09-22 14:40:00
![](https://img.aspxhome.com/file/UploadPic/20099/22/3829003347_68c759e3b7-72s.jpg)
如何优化下面这段代码?
2010-01-23 11:30:00
vue项目使用node连接数据库的方法(前后端分离)
2024-01-27 14:08:54
![](https://img.aspxhome.com/file/2023/6/139716_0s.png)
python+pytest接口自动化之session会话保持的实现
2021-10-15 15:45:31
![](https://img.aspxhome.com/file/2023/3/85183_0s.jpg)
IE6/7/8/9中Table/Select的innerHTML不能赋值的解决方法
2024-04-10 16:16:48
![](https://img.aspxhome.com/file/2023/0/136740_0s.png)
Python 中包/模块的 `import` 操作代码
2021-07-10 02:52:20
python继承threading.Thread实现有返回值的子类实例
2023-06-07 19:01:15
Python时间和字符串转换操作实例分析
2023-04-15 22:58:08
微信小程序开发常见问题及解决方案
2024-04-18 09:35:04
![](https://img.aspxhome.com/file/2023/1/136441_0s.png)
Jenkins使用publish html report插件展示HTML报告的方法
2022-03-31 19:30:54
![](https://img.aspxhome.com/file/2023/0/132300_0s.png)
javascript+css3开发打气球小游戏完整代码
2024-05-02 16:15:54
![](https://img.aspxhome.com/file/2023/1/132741_0s.gif)
服务器响应HTTP的类型ContentType大全
2007-10-23 10:21:00
图标设计常犯的10种错误
2008-03-06 13:40:00
![](https://img.aspxhome.com/file/UploadPic/20083/6/200836134649762s.jpg)
使用Python通过win32 COM实现Word文档的写入与保存方法
2021-03-16 04:09:27
![](https://img.aspxhome.com/file/2023/6/75226_0s.jpg)
MSSQL批量插入数据优化详细
2024-01-27 08:18:07
![](https://img.aspxhome.com/file/2023/6/108526_0s.png)
python如何求100以内的素数
2021-06-20 23:19:06
交互设计实用指南系列(2) –可及
2010-01-21 12:48:00
![](https://img.aspxhome.com/file/UploadPic/20101/21/sm11-73s.jpg)
详情解析TCP与UDP传输协议
2024-01-02 05:28:57
![](https://img.aspxhome.com/file/2023/3/109513_0s.png)
详解Pymongo常用查询方法总结
2022-06-01 09:13:30
![](https://img.aspxhome.com/file/2023/7/105387_0s.png)
python实现ip查询示例
2021-07-07 20:04:32