Edit your apache configuration file (/etc/apache2/sites-enabled/website.conf and /etc/apache2/httpd.conf for example).
<VirtualHost *:80> [...] ServerName example.com Redirect permanent / https://example.com/ </VirtualHost>
If you only redirect, you don't even need a document root.
Now restart Apache.
You can also use modrewrite, however the above method is simpler and safer. However, modrewrite below redirects the user to the page they were visiting over https, the above config just redirects to /:
<VirtualHost *:80> [...] <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} </IfModule> </VirtualHost>
And don't forget to restart Apache.
## Disable https on public site. Force redirect to http. RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !^(.*)/administrator/(.*)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d [OR] RewriteCond %{REQUEST_URI} . RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
It will first redirect HTTP to HTTPS and then it will redirect to https://www