……

thinkphp URL 解析一定要加index.php原因

方法一、可能mod_rewrite可能没安装或者没启用

1、httpd.conf 配置文件中加载mod_rewrite.so 模块;
2、AllowOverride None 将None 改为All;

方法二、隐藏index.php

可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则。
以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了该文件),内容如下:

Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

用的phpstudy,规则如下:

Options +FollowSymlinks -Multiviews 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

 

posted @ 2023-06-05 15:22  十零  阅读(191)  评论(0编辑  收藏  举报