Home > Backend Development > PHP Problem > Can php hide the suffix name?

Can php hide the suffix name?

WBOY
Release: 2023-03-16 11:48:01
Original
2127 people have browsed it

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
Copy after login

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]
Copy after login

Can php hide the suffix name?

2、修改apache配置文件:

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

开启rewrite模块:

LoadModule rewrite_module modules/mod_rewrite.so
Copy after login

保证:

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

Can php hide the suffix name?

重启apache:

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

使用浏览器访问:

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!

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