Dokuwiki redirect to https

If redirect from http to https is need and there is no success via .htaccess then PHP can help us:

'…lib/tpl/template-name/main.php'

  1. if ($_SERVER['HTTP_HOST'] != 'localhost' and $_SERVER['HTTP_X_FORWARDED_PROTO'] != "https") {
  2. $location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  3. header('HTTP/1.1 301 Moved Permanently');
  4. header('Location: ' . $location);
  5. }

Inspired by https://www.dokuwiki.org/tips:httpslogin