Thinkphp5.0隐藏入口文件

初始URL 样式

http://localhost/tp5/public/index.php/index

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

2.修改 index.php

// 定义应用目录
define('APP_PATH', __DIR__ . '/application/');
define('LOG_PATH', __DIR__ . '/log/');
// 加载框架引导文件
require __DIR__ . '/thinkphp/start.php';

\think\Log::init([
    'type'  =>  'File',
    'path'  =>  LOG_PATH,
    'level' => ['error']
]);

3.修改 .htaccess 文件


  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

这是我们最终想要的URL 样式

http://localhost/tp5/index

你可能感兴趣的:(Thinkphp5)