[modx] modx revo редирект с http на https через плагин

43

Вешаем плагин на событие OnHandleRequest.

<?php
if ($modx->event->name != "OnHandleRequest") {return;}

$site_url = 'site.ru'; // заменить на свой домен
$uri = $_SERVER['REQUEST_URI'];
$url = $_SERVER['HTTP_HOST'];

if ($uri == '/robots.txt') return;
if ($url != $site_url || !$_SERVER['HTTPS']) {
    $modx->sendRedirect('https://'.$site_url.$uri, array(
        'responseCode' => 'HTTP/1.1 301 Moved Permanently')
    );
}