php配置虚拟域名

1.找到apache的配置文件httpd.conf

2.在D:wampinapacheApache2.2.21confextrahttpd-vhosts.conf里面

3.重定向,不然访问其他的项目会出现403的错误

4.找到C:WindowsSystem32driversetchosts

5.最后一步别忘了重启apache服务器!

这样你配置的虚拟域名能访问了,用“127.0.0.1”或者“localhost”都能访问其他的项目了!

下面附上wamp2.5配置虚拟域名的步骤:

1:首先,打开apache的配置文件httpd.conf

2.找到这句话“Include conf/extra/httpd-vhosts.conf”,把前面的#去掉

3: 找到‘AllowOverride none ’改成‘AllowOverride All’(应该是两处)

找到这句‘Require all denied’(大概在242行),把denied改成granted(不该的话,试试可行不)

4.找到‘LoadModule rewrite_module modules/mod_rewrite.so ’把前面的#去掉(重定向,不去掉有可能出现比如验证码出不来的现象)

这样的话,可以在httpd-vhosts.conf文件里面直接这样配置:

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "E:/wamp/www/dsp2016_api"
ServerName api.dsp.com
</VirtualHost>

如果权限没配置好:试试下面的

<VirtualHost *:80>
DocumentRoot "D:/WWW/ceshici"
ServerName ci.zxj.com
ServerAlias phpStudy.net
<Directory "D:/WWW/ceshici">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

 
原文地址:https://www.cnblogs.com/hupengyin/p/4442728.html