main.php 1.02 KB
<?php

use yii\helpers\ArrayHelper;

/**
 * @author FilamentV <vortex.filament@gmail.com>
 * @copyright (c), Thread
 */
return ArrayHelper::merge(ArrayHelper::merge(require(dirname(__DIR__, 2) . '/common/config/main.php'), [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'sourceLanguage' => 'de-AT',
    'runtimePath' => '@runtime/frontend',
    'layoutPath' => '@app/layouts',
    'bootstrap' => require __DIR__ . '/bootstrap.php',
    'components' => require __DIR__ . '/components.php',
    'modules' => require(__DIR__ . '/modules.php'),
    'params' => require __DIR__ . '/params.php',
    // redirect to the page with the trailing slash
    'on beforeRequest' => function () {
        $app = Yii::$app;
        $pathInfo = $app->getRequest()->getPathInfo();
        if (!empty($pathInfo) && substr($pathInfo, -1) === '/') {
            header('Location: ' . $app->params['base']['baseUrl'] . '/' . rtrim($pathInfo, '/'), true, 301);
            exit();
        }
    },
]), require __DIR__ . '/main-local.php'
);