Home > PHP Framework > ThinkPHP > How to remove /public/index.php when accessing ThinkPHP5

How to remove /public/index.php when accessing ThinkPHP5

藏色散人
Release: 2021-06-08 08:57:43
forward
3281 people have browsed it

下面由thinkphp框架教程栏目给大家介绍ThinkPHP5访问怎么去除/public/index.php,希望对需要的朋友有所帮助!

How to remove /public/index.php when accessing ThinkPHP5

ThinkPHP5 访问去除/public/index.php

原访问链接:http://localhost/public/index.php/admin/index/index

设置后访问链接:http://localhost/admin/index/index

一、复制public目录下的index.php到根目录

修改内容为:

<?php
// 定义应用目录
define(&#39;APP_PATH&#39;, __DIR__ . &#39;./application/&#39;);
// 加载框架引导文件
require __DIR__ . &#39;./thinkphp/start.php&#39;;
Copy after login

二、在根目录新建.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>
Copy after login

 ThinkPHP简介:

ThinkPHP是为了简化企业级应用开发和敏捷WEB应用开发而诞生的。最早诞生于2006年初,2007年元旦正式更名为ThinkPHP,并且遵循Apache2开源协议发布。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进。

相关推荐:最新的10个thinkphp视频教程

The above is the detailed content of How to remove /public/index.php when accessing ThinkPHP5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template