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

查看:72
本文介绍了如何在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/ 查看全文

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