User:Cavila/Force request over https

Jump to navigation Jump to search


These are just requirements to allow for both http and https requests to be made:

$wgSecureLogin = true;
$wgServer = // /* 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 =

If you can access the config file on the server[edit]



Leaving out RewriteEngine On

(1) Global: everything/all traffic

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$$1 [R,L]

(2) Specific Domain

RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$$1 [R,L]

(3) Specific folder/wiki (here a folder called wiki)

RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} wiki
RewriteRule ^(.*)$$1 [R,L]

(4) Also came across this:

RewriteCond %{HTTPS} off  # or RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]