wampserver环境下如何配置虚拟域名?

1、添加虚拟域名

在C盘中找到C:\Windows\System32\drivers\etc下面的hosts文件然后打开配置,最好用管理员权限打开,新添虚拟域名,并保存

127.0.0.1 blog.cn

2、找到wamp64文件夹下面的bin\apache\apache2.4.23\conf。找到httpd.conf文件打开,然后搜索httpd-vhosts.conf,然后将

Include conf/extra/httpd-vhosts.conf

前面#号去掉,并保存

3、进行虚拟域名配置,找到打开apache/conf/extra下的配置文件httpd-vhosts.conf,配置如下

<VirtualHost *:80>
    ServerName blog.cn        ---->设置新添域名
    DocumentRoot e:/wamp64/www/blog           ---->设置网站根目录
    <Directory  "e:/wamp64/www/blog/">        ---->设置网站根访问目录
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

4、重启Apache,访问blog.cn/,就可以了

猜你喜欢

转载自blog.csdn.net/qq_40592933/article/details/88286576