如何将 URL 重定向到主机文件中的另一个 URL,而不是将 IP 重定向到 URL?
如何将 URL 重定向到主机文件中的另一个 URL,而不是将 IP 重定向到 URL?
How do I redirect a URL to another URL in the hosts file, rather than redirecting an IP to a URL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。 DNS(或主机文件)可让您查找给定的 IP 地址
主机名。在这个网络级别上不存在重新映射 URL 的概念。
这需要在您的 Web 服务器配置中完成。
You can't. DNS (or the host files) lets you look up IP addresses for a given
host name. There is no concept of remapping URLs at this level of networking.
This needs to be done in your web server configuration.
您可以安装localhost(MAMP,LAMP ..等),并将所有链接重定向到127.0.0.1,然后创建脚本以重定向到任何网站。
这是 PHP 示例
you can install localhost (MAMP ,LAMP ..etc) , and redirect all links to 127.0.0.1 , then create script to redirect to any website .
here's PHP example