User:Cavila/Force request over https
LocalSettings.php edit
These are just requirements to allow for both http and https requests to be made:
$wgSecureLogin = true;
$wgServer = //www.example.com /* Protocol-relative. Also affects use of fullurl */
("If the URL starts with https://, MediaWiki will assume that your wiki prefers the HTTPS protocol or supports it exclusively.")
Optionally add:
$wgCanonicalServer = https://www.example.com
If you can access the config file on the server edit
See http://httpd.apache.org/docs/current/rewrite/avoid.html#redirect
Apache/htaccess edit
Leaving out RewriteEngine On
(1) Global: everything/all traffic
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
(2) Specific Domain
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
(3) Specific folder/wiki (here a folder called wiki)
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} wiki
RewriteRule ^(.*)$ https://www.example.com/wiki/$1 [R,L]
(4) Also came across this:
RewriteCond %{HTTPS} off # or RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]