我想要的结果无非是去掉URL路径中的index.php
首先是配置.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
因为我部署在apache上面,需要httpd.conf配置文件中找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#,找到AllowOverride None改为AllowOverride All。
现在访问localhost/product有效,但是__APP__或者__URL__或者U获取出来的路径包含有index.php,也就是为localhost/index.php,原来还有一步,需要在conf/config.php里面修改或者添加'URL_MODEL'=>2,
而因为我尝试部署的是基于ThinkPHP的conist企业版2.0,在config.php里竟然有这么一个配置'URL_MODEL' =>C('TOKEN.false_static'),,而TOKEN.false_static的值在初始化的时候被设置为了1,所以。。。模式一直还是1,PATHINFO模式。
在新浪SAE部署,不支持.htaccess,只支持其自有的配置文件config.yaml,所以要在config.yaml添加下面这段重写格式代码:
handle:
- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1"
是不是超级简单呢,如果还想深入的学习其他伪静态方面的知识,请好好研读下下面的文章推荐吧。
标签:ThinkPHP,URL重写
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
mysql中错误:1093-You can’t specify target table for update in FROM clause的解决方法
2024-01-14 06:11:58
mysql8.0.21安装教程图文详解
2024-01-21 09:35:22
![](https://img.aspxhome.com/file/2023/2/115272_0s.png)
Python替换月份为英文缩写的实现方法
2023-07-19 10:20:45
![](https://img.aspxhome.com/file/2023/4/110494_0s.jpg)
Python实现的各种常见分布算法示例
2021-12-06 18:26:15
![](https://img.aspxhome.com/file/2023/1/76061_0s.png)
PS中执行N遍选定动作的脚本
2008-02-22 21:33:00
![](https://img.aspxhome.com/file/UploadPic/20082/22/2008222213917983s.gif)
go micro微服务proto开发安装及使用规则
2024-03-19 14:40:13
![](https://img.aspxhome.com/file/2023/0/99630_0s.png)
用户反馈对产品设计的帮助
2009-02-09 13:15:00
![](https://img.aspxhome.com/file/UploadPic/20092/9/blog02081-75s.jpg)
Python合并重叠矩形框
2023-06-11 02:33:41
![](https://img.aspxhome.com/file/2023/0/112460_0s.png)
使用python检测主机存活端口及检查存活主机
2021-08-01 05:20:27
![](https://img.aspxhome.com/file/2023/0/80550_0s.jpg)
python运行cmd命令行的3种方法总结
2023-07-15 18:40:49
php+mysql查询优化简单实例
2023-07-21 18:36:32
Python利用scapy实现ARP欺骗的方法
2021-07-24 08:26:03
![](https://img.aspxhome.com/file/2023/4/133674_0s.jpg)
解析PHP可变函数的经典用法
2024-06-05 09:38:32
django-crontab 定时执行任务方法的实现
2021-04-12 06:22:36
Mysql查询去空格的多种方法汇总
2024-01-25 02:27:18
![](https://img.aspxhome.com/file/2023/7/107927_0s.png)
vue 自定义右键样式的实例代码
2023-07-02 16:33:34
![](https://img.aspxhome.com/file/2023/7/139707_0s.png)
windows安装python超详细图文教程
2023-08-01 15:19:32
![](https://img.aspxhome.com/file/2023/2/61762_0s.png)
Pytorch中的backward()多个loss函数用法
2023-11-12 00:19:21
![](https://img.aspxhome.com/file/2023/1/99071_0s.png)
python逐行读取文件内容的三种方法
2023-01-05 14:07:30
详解Python中的循环语句的用法
2023-10-26 08:37:35