#用于显示设定“可显示文件列表”(当无可显示网页的时候)
Options Indexes
#启用文件夹访问控制的文件.htaccess设置
AllowOverride All
#请求控制
Require all granted
#默认打开的页面设置
DirectoryIndex index.php index.html
然后,找到hosts文件,win10的hosts文件路径为:
C:\Windows\System32\drivers\etc
#每个系统都不一样,可以去问问百度
在文件末尾处添加127.0.0.1 www.test.com(注意中间的空格不要丢),保存。
*如果保存提示另存为的话,可以先另存为,然后修改另存为的文件名为hosts,覆盖掉原来的hosts文件
...
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 www.test.com
修改hosts的目的是为了在浏览器访问时,系统不会把域名(www.test.com)提交到DNS服务器,而是直接根据hosts文件找到IP地址(此时是本地),提交解析。这样我们本地的服务器就可以解析这个域名了。 4、局域网远程访问
如果需要在局域网中能通过链接访问站点(例如开发web app时使用手机测试),那么就需要开启服务器远程访问权限了。
打开apache配置文件httpd.conf
安装目录\bin\apache\apache2.4.23\conf\httpd.conf
修改AllowOverride和Require配置为如下
DocumentRoot "${INSTALL_DIR}/www"
...
AllowOverride all
Require all granted
...
同时需要修改httpd-vhosts.conf文件,修改相同的配置
ServerName localhost
DocumentRoot D:/wamp64/www