怎样使用自定义域名代替localhost访问本地的php文件
其实很简单,只需两步:
1.打开hosts文件 C:\Windows\System32\drivers\etc\hosts,文件最末尾添加如下配置信息:
127.0.0.1 www.test.com(此为你自定义的域名,您可以根据自己的喜好定义)。
2. 打开apache的配置文件,在文件末尾添加如下配置信息:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "F:\Server\htdocs"
ServerName www.test.com
</VirtualHost>
至此,这样就搞定了,就这么简单,现在我们要访问本地web服务器上的index.php文件,就不用http://localhost/index.php或127.0.0.1/index.php了,而直接可以使用http://www.test.com/index.php,霸气吧!!
浙公网安备 33010602011771号