Home > Article > Backend Development > How to hide index.php in wamp
wamp隐藏index.php的方法:首先找到并打开“httpd-vhost.conf”文件;然后在“httpd-vhost.conf”文件下添加重写规则如“RewriteRule ^(.*)$/index.php/$1[L]...”即可。
本文操作环境:windows7系统、PHP7.1版,DELL G3电脑
wamp server虚拟主机设置index.php隐藏(入口文件隐藏)
注意使用wamp开发环境时,如果使用虚拟主机访问项目时需要将定义的重写规则必须在httpd-vhost.conf文件下添加重写规则,而不是自定义.htaccess文件,如下所示:
<VirtualHost *:80> //开启重写 RewriteEngine on //哪些文件路径不定义重写,我的css和js等文件是放在public路径下,所以在视图文件中以/public开头的url不重写路径(注意'/'需要使用'\’来进行转义) RewriteCond $1 !^(index\.php|\/public) //重写规则:可以不需要输入index.php来进行访问 RewriteRule ^(.*)$ /index.php/$1 [L] //虚拟主机路径 DocumentRoot "C:/****/project/lsm/" //虚拟主机访问地址自定义 ServerName lings.dev <Directory "C:/****/project/lsm/"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
推荐学习:《PHP视频教程》
The above is the detailed content of How to hide index.php in wamp. For more information, please follow other related articles on the PHP Chinese website!