Home >Backend Development >PHP Problem >How does Apache hide the index.php entry file?

How does Apache hide the index.php entry file?

coldplay.xixi
coldplay.xixiOriginal
2020-07-14 10:46:283618browse

Apache隐藏index.php入口文件的方法:首先检测Apache支持【mod_rewrite】;然后在【httpd.conf】里的AllowOverride None将None改为All;最近将内容保存为【.htacces】文件即可。

How does Apache hide the index.php entry file?

Apache隐藏index.php入口文件的方法:

1.检测Apache是否支持mod_rewrite
通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,其中列出了所有apache2handler已经开启的模块,如果里面包括“mod_rewrite”,则已经支持,不再需要继续设置。

如果没有开启“mod_rewrite”,则打开目录 您的apache安装目录“/apache/conf/” 下的 httpd.conf 文件,通过Ctrl+F查找到“LoadModule rewrite_module”,将前面的”#”号删除即可。
如果没有查找到,则到“LoadModule” 区域,在最后一行加入“LoadModule rewrite_module ,modules/mod_rewrite.so”(必选独占一行)

2.在httpd.conf里找到AllowOverride None 将None改为 All (PS:所有的AllowOverride对应的None都改为ALL)

3.把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

以上操作全部都完成,重启apache

相关学习推荐:PHP编程从入门到精通

The above is the detailed content of How does Apache hide the index.php entry file?. 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