Home > Article > Backend Development > How to hide suffix name in php
php隐藏后缀名的方法是:1、在htdocs根目录下新建htaccess文件并编辑;2、修改apache配置文件,开启rewrite模块;3、重启apache服务器即可。
具体方法:
(推荐教程:apache)
首先在apache服务器下htdocs根目录下创建文件.htaccess,编辑以下内容:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [L]
然后修改apache配置文件:
/usr/local/httpd/conf/httpd.conf
开启rewrite模块:
LoadModule rewrite_module modules/mod_rewrite.so
保证:
Allowoverride ALL(配置文件有多个,请注意上下文)
最后重启apache
/usr/local/httpd/bin/apachectl restart
相关推荐:php培训
The above is the detailed content of How to hide suffix name in php. For more information, please follow other related articles on the PHP Chinese website!