Home > PHP Framework > ThinkPHP > How to hide entry files in thinkphp

How to hide entry files in thinkphp

Release: 2020-05-01 09:05:53
forward
3365 people have browsed it

How to hide entry files in 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();
Copy after login

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>
Copy after login

最终url样式:http://localhost/tp5/index

推荐教程:《TP5

The above is the detailed content of How to hide entry files in thinkphp. 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