我在我的 Ubuntu 安装(13.04,如果有帮助的话)上安装了一个 apache2 服务器,用于个人编程测试,我想知道当我输入 fakedomainname.dev
时是否有可能。 ,它重定向到 localhost/testingSite
.我已经研究过编辑 /etc/hosts
文件,但这只允许我重定向到一个 IP 地址,我认为 localhost 页面没有自己的 IP 地址(是吗?),所以这不起作用。我可以通过localhost/testingSite
访问当前页面,但能够输入 fakedomainname.dev
会很有趣反而。
谢谢!
PS...这应该发布在 Ask Ubuntu 而不是 Stack Overflow 上吗?我不确定它是否被认为足够特定于 Ubuntu,所以我把它贴在这里。如果我放错了,请移步!
最佳答案
重定向到 127.0.0.1
-- 相当于本地主机。
这是我的/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 上运行的 flask 应用程序,我现在可以通过 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]
关于apache - 将域请求重定向到 localhost/子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18776955/