首頁  >  文章  >  php框架  >  thinkphp中隱藏入口檔案的方法

thinkphp中隱藏入口檔案的方法

尚
轉載
2020-05-01 09:05:533241瀏覽

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

以上是thinkphp中隱藏入口檔案的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除