Мы создали расширенное приложение yii и изменили URL-адреса на чистые URL-адреса, а .htaccess
в нашей папке root выглядит следующим образом:
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^admin(/.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
и .htaccess
в frontend/web/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
и main.php
из frontend/config/
выглядит следующим образом
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
use \yii\web\Request;
$baseUrl = str_replace('/frontend/web', '', (new Request)->getBaseUrl());
return [
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
// 'defaultRoute' => 'site/program',
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
'baseUrl' => $baseUrl,
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => 'advanced-frontend',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'baseUrl' =>$baseUrl,
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
]
]
],
'params' => $params,
];
, и теперь проблема заключается в том, что действия по умолчанию, возникающие при создании проекта, работают как login
, signup
, about
, contact
и defaultroute
работают. Кроме этого, любое новое действие не работает и выдает ошибку как yii\base\InvalidRouteException: Unable to resolve the request
, где мы ошиблись, почему defaultroute
работает и другие действия в том же контроллере не работают. Пожалуйста, предложите нам правильный путь.