Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to block (not redirect) access to a website via http, but not if the user types in https.

I am using Windows 7. How can this be done?

share|improve this question
What browser? Or should it be system-wide? – Tom Wijsman Aug 16 '10 at 0:51
Using the host file this is impossible unless they host ssl on another server ip address. – David Remy Aug 16 '10 at 1:14

This is not possible. The HOSTS file only affects DNS requests. When your browser requests, the computer does a DNS lookup on When your browser requests, it also does a DNS lookup on, and the result will always be the same for either, because they're the same. http vs https is just a different protocol.

To address your larger question of how to block it, what is your environment? Is this just a home computer, or are you doing this for a large number of computers in a corporate environment? Some more details on your needs and this situation would be helpful for solving your problem.

share|improve this answer

As other answers have said this cannot be done with the HOSTS file.

It can be done with Windows Firewall. Add an outbound rule to block http to the site (the default rule for outbound is allow, so you only need rules where you want to block).

share|improve this answer

Go into Control Panel & Internet Options. On the Security tab, under Restricted Sites, add the URL of the http version of the site. If you wish, you can add the https URL under Trusted Sites.

This won't block access completely but will disable virtually all functionality other than just straight rendering of the HTML.

An alternative may be to use a proxy server.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .