gpt4 book ai didi

osx-elcapitan - MacOS 仅托管非 www 网址的文件条目

转载 作者:行者123 更新时间:2023-12-04 06:05:46 25 4
gpt4 key购买 nike

我正在运行 MacOSX 10.11.4。

我想让 example.com 指向我本地运行的 apache 服务器,但让 www.example.com 指向实际网站。

例子:
我的/etc/hosts 文件中有以下条目:127.0.0.1 example.com如果我 ping example.com 和 www.example.com,它们都会达到 127.0.0.1(我相信是因为规范 URL 被认为是相同的)。

有趣的是,Chrome 会根据需要提取 URL,但 Firefox 会同时访问 localhost。

——

编辑:我知道使用 example.local 之类的东西更传统,可以完全避免这个问题;但是,我的工作已经使用 www/non-www 方法有一段时间了,如果可能的话,我想保留它。

最佳答案

这可能太容易了,但你为什么不把

example.com     127.0.0.1
www.example.com 123.52.232.12

进入您的 /etc/hosts文件,其中 123.52.232.12 是真实 example.com 站点的 IP 地址?

why it's happening or how to stop both domains from going to my hosts file



这是默认的解析顺序,使用 the hosts file子域的自动扩展。 solution by @fragmentedreality使用 dnsmasq 解析器提供了一种解决方法,在 https://serverfault.com/questions/431605/dont-automatically-include-all-subdomains-in-dnsmasq-address 中也推荐使用该解析器。并在 https://gist.github.com/ogrrd/5831371 中描述.

关于osx-elcapitan - MacOS 仅托管非 www 网址的文件条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41391650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com