Tutorial :How to add entry in windows “host file” such that it can redirect over https



Question:

I want to redirect all my browser request to abc.com when a request is sent to xyz.com I was able to do this by adding an entry in the hosts file under windows.

However I see that i can go to http://abc.com when i type in http://xyz.com:8080 but I cannot seem to get the same redirection over https.

I found out that you cannot mention ports in the host file. Need some help on this


Solution:1

That's not what the hosts file is for. It's about the hosts that you are referring to. abc.com and xyz.com are hosts.

All the hosts file does is associate a host name with an IP address. Nothing else is possible.


Solution:2

HTTPS is specifically designed so that you can't do this - not only is one of the core points of SSL/TLS that the conversation be encrypted, it also ensures that you really are talking to who you think you are, that you haven't been redirected to a fake site via DNS.


Solution:3

Get a clone of the part you need from the genuine site.. put it on local iis, add ssl binding using self signed certificate and add entry to hosts file.http://www.selfsignedcertificate.com. if you are in rush with no time to play with iis mgr use appcmd.

Youll get a not verified warning for untrusted issuer.. add it to trusted root cert authorities. http://www.robbagby.com/iis/self-signed-certificates-on-iis-7-the-easy-way-and-the-most-effective-way/

Never tried self signed cert tho.. let us now how your testinggoes.


Solution:4

With HTTPS, it'll be to do with the security certificate - likely you can't get around that, or at least ... I hope not.


Solution:5

A hosts file is DNS, which is used to resolve a domain name to an IP addresses, which has nothing to do with ports.

If you redirect from https://abc.com to https://xyz.com then they will need to be different servers with different certificates, as an SSL certificate is bound to the domain name.

Which means if you use your hosts file to lookup the ip address of abc.com when you try https://xyz.com then it wont work as the certificate will be for abc.com and wont match the hostheader https://xyz.com sent by your browser.


Solution:6

If you are using windows command for routing:

netsh interface portproxy add v4tov4 listenport=listen_port listenaddress=any_free_ip_address connectport=localhost_port connectaddress=127.0.0.1  

The default port for http request is 80 so if one is using https use 443 as it is the default for https


Solution:7

Use nslookup xyz.com and get IP

then put this IP to hosts (/etc/hosts in Linux)

the https domain name must transform to IP from


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »