Home  >  Article  >  Backend Development  >  How to hide .php in thinkphp

How to hide .php in thinkphp

藏色散人
藏色散人Original
2020-11-25 10:16:301886browse

thinkphp隐藏index.php的方法:首先修改apache中httpd.conf文件;然后在项目中修改配置文件“config.php”,并修改URL模式为2;最后创建.htaccess文件,并重启apache即可。

How to hide .php in thinkphp

本教程操作环境:Windows7系统、PHP5.6版,该方法适用于所有品牌电脑。

推荐:《PHP视频教程

ThinkPHP中隐藏index.php

一、修改apache中httpd.conf文件

  1. 找到#LoadModule rewrite_module modules/mod_rewrite.so,将前面"#"去掉;

  2.找到所有AllowOverride None,将其改为AllowOverride All;

二、在自己项目中修改配置文件(Con/config.php),修改URL模式为2

'URL_MODEL'             => 2,       // URL访问模式,可选参数0、1、2、3,代表以下四种模式:

三、在入口文件index.php处创建.htaccess文件,添加一下内容

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

四、重启apache即可

The above is the detailed content of How to hide .php in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

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