Home  >  Article  >  Backend Development  >  Can php hide the suffix name?

Can php hide the suffix name?

WBOY
WBOYOriginal
2022-06-16 16:14:002103browse

PHP能隐藏后缀名。隐藏后缀名的方法:1、在apache服务器下htdocs根目录下创建“.htaccess”文件并编辑指定的内容;2、修改apache配置文件,并且开启rewrite模块;3、利用“/usr/local/httpd/bin/apachectl restart”重启apache服务器即可。

Can php hide the suffix name?

本文操作环境:Windows10系统、PHP8.1版、Dell G3电脑

php能隐藏后缀名吗

php能隐藏后缀名

在没有任何设置的情况下,我们访问下index.php和index:

127.0.0.1/index.php
127.0.0.1/index

Can php hide the suffix name?

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

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

Can php hide the suffix name?

2、修改apache配置文件:

/usr/local/httpd/conf/httpd.conf

开启rewrite模块:

LoadModule rewrite_module modules/mod_rewrite.so

保证:

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

Can php hide the suffix name?

重启apache:

/usr/local/httpd/bin/apachectl restart

使用浏览器访问:

127.0.0.1/index

Can php hide the suffix name?

推荐学习:《PHP视频教程

The above is the detailed content of Can php hide the suffix name?. 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