初始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》
以上就是thinkphp中隐藏入口文件的方法的详细内容。