1.首先我们要保证apach的两个东西是开启的

 但是两个都是在同一个文件:httpd.conf

C:\phpStudy\Apache\conf(这是我的电脑默认路径)

1.打开 LoadModule rewrite_module modules/mod_rewrite.so(这个默认是打开的)

2.打开 Include conf/extra/httpd-vhosts.conf(这个需要手动开启,把#去掉就好了)

2.找到httpd-vhostss.conf

 C:\phpStudy\Apache\conf\extra(一般都是这样对应)

 添加如下代码::

 <VirtualHost 127.0.0.15:80>
     ServerAdmin [email protected]
     DocumentRoot "C:/xampp/htdocs/test"(这个是文件的根目录)
     ServerName  state.com(这个是虚拟域名)
     ErrorLog "logs/dummy-host2.dons.com-error.log"
     CustomLog "logs/dummy-host2.dons.com-access.log" common
 <Directory "C:/xampp/htdocs/test"> (这个必须和上面的文件根目录同名)
         Options Indexes FollowSymLinks
         DirectoryIndex index.html index.php
         AllowOverride all
         Order allow,deny
         Allow from all
     </Directory>
 </VirtualHost>

3.找到hosts文件(这个所有人都是相同的)

 在:C:\Windows\System32\drivers\etc下面添加:

127.0.0.15       state.com

php本地虚拟域名配置 适用小白

就像这样,记住:ip对应,域名对应,然后重启服务器就可以直接访问了



相关文章: