TP5如何隐藏入口文件index.php

一、Apache

在ThinkPHP5.0中,出于优化的URL访问原则,还支持通过URL重写隐藏入口文件,下面以Apache为例说明隐藏应用入口文件index.php的设置。

下面是Apache的配置过程,可以参考下:
1、httpd.conf配置文件中加载了mod_rewrite.so模块
2、AllowOverride None 将None改为 All
3、在应用入口文件同级目录添加.htaccess文件,内容如下:
<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>
4、重启Apche;

二、Nginx

打开nginx配置文件

[root@iZ2ze4soc7gff7oypswfa4Z ~]#cd /etc/nginx/conf.d/

[root@iZ2ze4soc7gff7oypswfa4Z conf.d]# vi default.conf

<>
location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.*)$
/index.php?s=/$1 last; break; } }

友情链接
ioDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信