ThinkPHP5訪問去除/public/index.php

原訪問鏈接:http://localhost/public/index.php/admin/index/index
設置後訪問鏈接:http://localhost/admin/index/index

一、複製public目錄下的index.php到根目錄

在這裏插入圖片描述
修改內容爲:

<?php
// 定義應用目錄
define('APP_PATH', __DIR__ . './application/');
// 加載框架引導文件
require __DIR__ . './thinkphp/start.php';

二、在根目錄新建.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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章