php 如何在我的本地主机上创建子域?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18793883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make subdomain on my localhost?
提问by Mehman Manafov
is it possible to create subdomains on my localhost? like sub.localhost
and would like to know how subdomains work.
是否可以在我的本地主机上创建子域?喜欢sub.localhost
并想知道子域是如何工作的。
回答by SeanWM
回答by SAnDAnGE
You can make your browser to point to any domain/subdomain that you want as long as you put the ip - hostname definition in your c:\Windows\System32\drivers\etc\hosts
file, for example:
只要将 ip - 主机名定义放在c:\Windows\System32\drivers\etc\hosts
文件中,您就可以让浏览器指向您想要的任何域/子域,例如:
127.0.0.1 localhost
127.0.0.1 sub.localhost
127.0.0.1 本地主机
127.0.0.1 子本地主机
or on the same line separate by space:
或在以空格分隔的同一行上:
127.0.0.1 sub.localhost subsub.localhost local.host
127.0.0.1 sub.localhost subsub.localhost local.host
回答by Athens Holloway
Add the following to your local hosts file. On windows, it's located at C:\WINDOWS\system32\drivers\etc\hosts
.
将以下内容添加到本地主机文件中。在 Windows 上,它位于C:\WINDOWS\system32\drivers\etc\hosts
。
127.0.0.1 sub.localhost
Replace 127.0.0.1
with whatever IP address you want.
替换127.0.0.1
为您想要的任何 IP 地址。