yii\base\InvalidRouteException:无法解析yii2中的请求



我们已经创建了高级yii应用程序,并将URL更改为干净URL,根文件夹中的.htaccess如下

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]

CCD_ 3中的CCD_

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php

CCD_ 4和CCD_

$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 yiiwebRequest;
$baseUrl = str_replace('/frontend/web', '', (new Request)->getBaseUrl());
return [
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
//  'defaultRoute' => 'site/program',
'bootstrap' => ['log'],
'controllerNamespace' => 'frontendcontrollers',
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
'baseUrl' => $baseUrl,
],
'user' => [
'identityClass' => 'commonmodelsUser',
'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' => 'yiilogFileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'baseUrl' =>$baseUrl,
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
]
]
],
'params' => $params,
];

现在的问题是,创建项目时出现的默认操作像loginsignupaboutcontactdefaultroute一样工作。除此之外,任何新操作都不起作用,并将错误显示为yiibaseInvalidRouteException: Unable to resolve the request我们哪里做错了,为什么defaultroute工作,而同一控制器中的其他动作不工作。请以正确的方式向我们推荐。

当操作名称为小写时,有效,但如果在操作名称中使用任何大写字母,则无效。就像actionContactmenu在哪里工作一样,actionContactmenu不工作是什么原因让我们知道。。。。

为此,您必须将其称为联系人菜单,而不是联系人菜单。

最新更新