thinkphp中如何隐藏入口文件

2023-06-14

这篇文章主要介绍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

以上是“thinkphp中如何隐藏入口文件”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注本站行业资讯频道!

《thinkphp中如何隐藏入口文件.doc》

下载本文的Word格式文档,以方便收藏与打印。