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 文件

立即學習PHP免費學習筆記(深入)”;

<ifmodule> ??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

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊9 分享