您好,欢迎来到递易科技网。
搜索
您的当前位置:首页thinkphp中隐藏入口文件的方法

thinkphp中隐藏入口文件的方法

来源:递易科技网


初始url样式:http://localhost/tp5/public/index.php/index

1、将 index.php 和 .htacess 文件移出到和Public 文件平级目录;

2、修改 index.php

namespace think;
 
// 加载基础文件
require __DIR__ . '/thinkphp/base.php';
 
// 支持事先使用静态方法设置Request对象和Config对象
 
// 执行应用并响应
Container::get('app')->run()->send();

3、修改 .htaccess 文件

<IfModule mod_rewrite.c>
 Options +FollowSymlinks -Multiviews
 RewriteEngine On
 
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>

最终url样式:http://localhost/tp5/index

推荐教程:《TP5》

Copyright © 2019- diyibofang.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务