Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

This is not possible. The HOSTS file only affects DNS requests. When your browser requests http://example.com/, the computer does a DNS lookup on example.com. When your browser requests https://example.com/, it also does a DNS lookup on example.com, 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.