2

我在我的 Ubuntu 安装(13.04,如果有帮助的话)上安装了一个 apache2 服务器,用于个人编程测试,我想知道是否有可能,当我输入 时fakedomainname.dev,它会重定向到localhost/testingSite. 我已经研究过编辑该/etc/hosts文件,但这只允许我重定向到一个 IP 地址,我认为 localhost 页面没有自己的 IP 地址(是吗?),所以这不起作用。我可以通过 访问当前的页面localhost/testingSite,但是能够进入会很有趣fakedomainname.dev

谢谢!

PS...这应该发布在 Ask Ubuntu 而不是 Stack Overflow 上吗?我不确定它是否被认为足够特定于 Ubuntu,所以我把它贴在这里。如果我放错了,请移步!

4

1 回答 1

1

重定向到127.0.0.1-- 相当于 localhost。

这是我的 /etc/hosts 文件:

root@vagrant:~# cat /etc/hosts
127.0.0.1   localhost   stuff.dev
127.0.1.1   vagrant.vm  vagrant

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我有一个在端口 8000 上运行的烧瓶应用程序,我现在可以通过 stuff.dev:8000 访问它

root@vagrant:~# wget stuff.dev:8000
--2013-09-13 02:22:14--  http://stuff.dev:8000/
Resolving stuff.dev (stuff.dev)... 127.0.0.1
Connecting to stuff.dev (stuff.dev)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2 [text/html]
Saving to: ‘index.html’

100%[================================================================================================================================================================>] 2           --.-K/s   in 0s

2013-09-13 02:22:14 (229 KB/s) - ‘index.html’ saved [2/2]
于 2013-09-13T02:04:32.860 回答