如何在 Mac 上的本地主机上测试子域? [英] How to test sub-domains on my localhost on a mac?

查看:30
本文介绍了如何在 Mac 上的本地主机上测试子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个 Web 应用程序,并在我的本地主机上运行它.即 - http://127.0.0.1:8000/.我也设置了子域.例如,去 http://blog.127.0.0.1:8000/ 应该带我去博客部分.但是,我的浏览器无法识别这一点,并说找不到服务器.我的操作系统是 MACOSx

I have set up a web application on I am running it on my localhost. That is - http://127.0.0.1:8000/. I have set up sub-domains as well. For example, going to http://blog.127.0.0.1:8000/ should take me to the blog part. However, my browser does not recognize this and says server cannot be found. My OS is MACOSx

如果您想在本地主机上测试子域,则需要您的浏览器将多个子域解析为127.0.0.1".您执行此操作的方式取决于您的操作系统.如果您使用的是 linux,则需要编辑/etc/hosts.

If you want to test subdomains on your local host, you need your browser to resolve multiple subdomains as '127.0.0.1'. The way you do this depends on your OS. If you're using linux, you would edit /etc/hosts.

我从另一个用户那里得到了一些信息,但是,我不知道如何在我的 Mac 上执行此操作.任何帮助表示赞赏.

I got this bit of info from another user, however, I have no idea how to do this on my Mac. Any help is appreciated.

推荐答案

编辑文件/etc/hosts,添加如下一行:

Edit the file /etc/hosts, add the following line:

127.0.0.1 example.com blog.example.com

然后尝试 http://example.com:8000/http://blog.example.com:8000/

这篇关于如何在 Mac 上的本地主机上测试子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆