当前位置: 移动技术网 > 网络运营>服务器>Windows > apache 配置模拟外网环境开发网站的方法

apache 配置模拟外网环境开发网站的方法

2019年04月21日  | 移动技术网网络运营  | 我要评论

因为很多程序员在开发时都会在apache指定的网站目录下建一个文件夹放网站,当在本机测试时就是输入http://127.0.0.1/web1/这样访问网站,但上传到网站后是用域名的,这样就会造成路径不正确。
解决方法:
在c:\windows\system32\drivers\etc目录下找到hosts文件,用文本打开,在里面加一句
127.0.0.1 emtit.com
这样你就可以不设dns服务器就可以用www.emtit.com访问你的网站了,但这样还不能到达你的虚拟目录,打开apache的httpd.conf配置文件,在里面加上下面的代码

复制代码 代码如下:

namevirtualhost *:80
<virtualhost *:80>
serveradmin hjwtp2005@163.com
documentroot /flashgame
servername emtit.com
serveralias www.emtit.com
errorlog @rel_logfiledir@/dummy-host.example.com-error_log
customlog @rel_logfiledir@/dummy-host.example.com-access_log common
</virtualhost>

这样你就可以不设dns就可以像访问外网一样访问本机的网站了。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网