PHP能隐藏后缀名。隐藏后缀名的方法:1、在apache服务器下htdocs根目录下创建“.htaccess”文件并编辑指定的内容;2、修改apache配置文件,并且开启rewrite模块;3、利用“/usr/local/httpd/bin/apachectl restart”重启apache服务器即可。
本文操作环境:Windows10系统、PHP8.1版、Dell G3电脑
php能隐藏后缀名
在没有任何设置的情况下,我们访问下index.php和index:
127.0.0.1/index.php 127.0.0.1/index
1、在apache服务器下htdocs根目录下创建文件.htaccess,编辑以下内容:
立即学习“PHP免费学习笔记(深入)”;
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [L]
2、修改apache配置文件:
/usr/local/httpd/conf/httpd.conf
开启rewrite模块:
LoadModule rewrite_module modules/mod_rewrite.so
保证:
Allowoverride ALL(配置文件有多个,请注意上下文)
重启apache:
/usr/local/httpd/bin/apachectl restart
使用浏览器访问:
127.0.0.1/index
推荐学习:《PHP视频教程》
以上就是php能隐藏后缀名吗的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号