url manager

Общие вопросы по использованию второй версии фреймворка. Если не знаете как что-то сделать и это про Yii 2, вам сюда.
Ответить
shon
Сообщения: 29
Зарегистрирован: 2017.02.10, 14:13

url manager

Сообщение shon »

Развернул на локальной машине basic приложения, после чего активировал urlManager, все корректно работает. Но на удаленном сервере, выдает 404 всех страницах кроме "/". На локальной машине используется openserver(apache), на удаленном сервере nginx.

Код: Выделить всё

<?php

$params = require(__DIR__ . '/params.php');
$db = require(__DIR__ . '/db.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log','Init'],
    'components' => [
        'Init'=>[
            'class'=>'app\components\Init'
        ],

        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '123456',
            'baseUrl' => ''
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => $db,
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,
            'rules' => array(
                '/' => 'site/about',
                '<module:[\wd-]+>/<controller:[\wd-]+>/<action:[\wd-]+>/<param:>' => '<module>/<controller>/<action>'

            ),
        ],
    ],
    'modules' => [
        'orders' => [
            'class' => 'app\modules\orders\orders',
        ],
    ],
    'params' => $params,
    'language' => 'ru-RU',
    'sourceLanguage' => 'ru-RU',
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['*'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
//        'allowedIPs' => ['213.135.85.78', '::1','127.0.0.1',],
        'allowedIPs' => ['*'],
    ];
}

return $config;
В какую сторону стоит копать?
Аватара пользователя
ElisDN
Сообщения: 5845
Зарегистрирован: 2012.10.07, 10:24
Контактная информация:

Re: url manager

Сообщение ElisDN »

shon писал(а): 2018.02.08, 20:25 В какую сторону стоит копать?
В сторону настройки Nginx.
shon
Сообщения: 29
Зарегистрирован: 2017.02.10, 14:13

Re: url manager

Сообщение shon »

ElisDN писал(а): 2018.02.08, 20:37
shon писал(а): 2018.02.08, 20:25 В какую сторону стоит копать?
В сторону настройки Nginx.
Спасибо. Рекомендованные в статье настройки помогли.
Ответить