ThinkPHP6.0 重写URL去掉Index.php的解决方法
2021-02-01 04:06
706 查看
踩坑!
官网给的解决方案: 解决重写URL,省去index.php问题
可以通过URL重写隐藏应用的入口文件index.php,下面是相关服务器的配置参考:
[ Apache ]
httpd.conf配置文件中加载了mod_rewrite.so模块
AllowOverride None 将None改为 All
把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] </IfModule>
官网文档中给的 .htaccess 文件内容如下
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] #这一行踩坑 </IfModule>
正确的写法应该如下,官网给的最后一行配置错误
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] #这才是对的 </IfModule>
结尾
解决问题最好多看看官方给的文档,但有时候也不能全看官网文档,可以结合官网下面的讨论区,借鉴各个大佬们的回答去解决问题
相关文章推荐
- thinkphp在wamp 配置去掉url中index.php方法
- ThinkPHP如何URL如何去掉index.php(重写模式)
- thinkPHP隐藏url地址栏中的index.php方法
- ThinkPHP的URL重写时遇到No input file specified的解决方法
- ThinkPHP 在nginx环境下去掉URL中的index.php
- ThinkPHP去掉URL中的index.php
- Apache下简化URL,去掉index.php的方法
- ThinkPHP 在nginx环境下去掉URL中的index.php
- 去掉thinkphp的url中的index.php
- ThinkPHP去掉URL中的index.php
- ThinkPHP中通过URL重写隐藏应用的入口文件index.php的相关服务器的配置
- thinkphp消除URL中index.php的方法
- laravel框架实现去掉URL中index.php的方法
- ThinkPHP的URL重写时遇到No input file specified的解决方法
- ThinkPHP框架中隐藏index.php无效解决方法
- thinkphp 去掉URL 里面的index.php
- CI 框架去掉url 中index.php的方法
- thinkPHP如何去掉url中的index.php
- thinkphp项目在apache服务器中“去掉”index.php后出现找不到url的问题
- thinkphp在nginx没有pathinfo的情况出现.php的URL的解决方法