tp5 地址隐藏省略public和index.php

版权声明:Yangliwei 版权所有 https://blog.csdn.net/qq_32674347/article/details/87810548

1,把public目录中的index.php移至根目录,并修改:

<?php
// [ 应用入口文件 ]

// [ 应用入口文件 ]
namespace think;

// 加载基础文件
require __DIR__ . './thinkphp/base.php';

// 执行应用并响应
Container::get('app')->run()->send();

2,把.htaccess文件也从public文件夹移至根目录,并修改:

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

 index.php修改如下图:

猜你喜欢

转载自blog.csdn.net/qq_32674347/article/details/87810548
今日推荐