扫码关注官方订阅号
为什么我的按照老师的放到index文件下访问的时候路径变成这样才能访问?
http://tp6.com/index.php/index/index/admin
这里说的入口文件指的是公共/ index.php文件,配置文件就在这个目录下可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则。以Apache为例,在需要文件入口的同级添加.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> 如果用的phpstudy,规则如下: <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>
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这里说的入口文件指的是公共/ index.php文件,配置文件就在这个目录下可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则。以Apache为例,在需要文件入口的同级添加.htaccess文件(官方默认自带了该文件),内容如下: