This is about web development and nagios monitoring.

Redirect HTTP to HTTPS using Apache and htaccess

Written from Klement

If you're having a SSL certificate for your website and want to redirect the visitors from HTTP to HTTPS for all pages you can do this by adding three simple rules via htaccess (mod_rewrite). You may already have a .htaccess file in the root folder of your website with some other rules. Then you can just edit this file and add the ReqriteCond and RewriteRule. Otherwise create a new file called .htaccess, add the fallowing lines to the file and upload it to the root folder of your website.

#Activate rewrite engine
RewriteEngine On

#Check if visitor is already coming via HTTPS. If not process to the Rewrite Rule
RewriteCond %{HTTPS} off

#Redirects all requests to HTTPS
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Matches all requests and rewrites them

Variable for your domain like (more info to find here)

Variable for your path like /subsite/news.html (more info to find here)

HTTP status code 301 (permanent redirect) will be used for the redirect. This is the best way for search engines when they update your links to HTTPS without any loss (more info to find here).

No further rules will be processed if the rule matches (more info to find here).