编辑主机文件以重定向网址? [英] Editing hosts file to redirect url?
问题描述
我知道您可以编辑主机文件以将 URL 重定向到 IP 地址,如下所示:
I know you can edit a hosts file to redirect a URL to an IP address as so:
127.0.0.1 google.com
127.0.0.1 google.com
但是如何强制重定向到 URL 而不是 IP 地址?
but how do you force a redirect to a URL instead of an IP address?
例如
mysite.com/welcome.aspx google.com
mysite.com/welcome.aspx google.com
显式 URL 不起作用,假设 mysite.com 的 IP 是 222.222.222.222,以下也不起作用:
The explicit URL doesn't work and assuming mysite.com's IP is 222.222.222.222, the following doesn't work either:
222.222.222.222/welcome.aspx google.com
222.222.222.222/welcome.aspx google.com
推荐答案
否,但您可以在例如 127.0.0.77 打开一个 Web 服务器并使用它来检查请求 URI 是否为/welcome.aspx"...如果是重定向到谷歌,如果不加载原始站点.
No, but you could open a web server at, for example, 127.0.0.77 and use it to check if the Request URI is "/welcome.aspx"... If yes redirect to google, if not load the original site.
127.0.0.77 mysite.com
这篇关于编辑主机文件以重定向网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!