How to exclude HTTP. Only need HTTPS.

October 1, 2014 2.8k views

I have a website that is controlled by speech-recognition software. The user does not control the website. This website needs to be HTTPS only! I followed this document
to set up the HTTPS: How To Set Up Apache with a Free Signed SSL Certificate on a VPS.

I got it to work but now I want to remove HTTP.

I assume I have to do the following:

  1. nano /etc/apache2/sites-enabled/000-default and remove <VirtualHost *:80>

  2. sudo ufw deny http

I want to be able to use “” or “” and have it resolve to “https://....”

Is there anything else I need to do to make this happen?

  • or.....

    you can just use an .htaccess file in your sites root directory and paste this into it:

    <IfModule mod_rewrite.c>
    #redirect www to website root
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    #force https 
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    if you do not already, you would need mod_rewrite enable in order to use this.

  • My apologies for not indicating that I am using Ubuntu 12.04. The reference to the doc How to set up HTTPS in Apache web Server on CentOS was helpful in that it helped me to understand what I needed to do additional research on. I found this document How To Create Temporary and Permanent Redirects with Apache and Nginx. It lead me to additional information which helped to resolve the problem. Thanks.

    by Justin Ellingwood
    HTTP redirects are used to redirect web site visitors to new locations when they request content. These are useful for a variety of reasons, whether permanent or temporary. This guide will demonstrate how to redirect visitors using Apache and Nginx.
1 Answer

Assuming you are using centos check out this tutorial

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!