- Instant help with your Developer coding problems

Automatically redirect HTTP to HTTPS on Apache webservers

Question:
How to automatically redirect HTTP to HTTPS on Apache webservers?
Answer:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Description:

To automatically redirect all requests from HTTP to HTTPS you can use Apache's mod_rewrite module. This is a good solution to force your site visitors to use SSL. Besides this, you can also apply this solution on most shared hosting plans where you have access to the htaccess file.

Share "How to automatically redirect HTTP to HTTPS on Apache webservers?"
Tags:
automatically redirect http to https, redirect http to https, http, https, ssl, apache
Technical term:
Automatically redirect HTTP to HTTPS on Apache webservers