Home > Backend Development > PHP Problem > What is the method to hide php suffix

What is the method to hide php suffix

王林
Release: 2023-03-07 14:24:02
Original
3368 people have browsed it

隐藏php后缀的方法是:1、在htdocs根目录下新建htaccess文件,并添加配置【RewriteEngine On】;2、编辑apache配置文件,开启rewrite模块;3、重启apache。

What is the method to hide php suffix

具体方法如下:

(学习视频推荐:java视频教程

1、在apache服务器下htdocs根目录下创建文件.htaccess,编辑以下内容:

RewriteEngine On
 
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteCond %{REQUEST_FILENAME}\.php -f
 
RewriteRule ^(.*)$ $1.php [L]
Copy after login

2、修改apache配置文件:

/usr/local/httpd/conf/httpd.conf
Copy after login

开启rewrite模块:

LoadModule rewrite_module modules/mod_rewrite.so
Copy after login

保证:

Allowoverride ALL(配置文件有多个,请注意上下文)
Copy after login

3、重启apache:

/usr/local/httpd/bin/apachectl restart
Copy after login

相关推荐:php培训

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

Related labels:
source:php.cn
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