We have created the advanced yii app and changed the urls to clean urls and the .htaccess
in our root folder is as follows
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]
and .htaccess
in frontend/web/
is as follows
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php
and main.php
from frontend/config/
is as follows
$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, ];
and now the problem is that default actions that come while creating project are working like login
, signup
, about
, contact
and defaultroute
are working. Other than these, any new action is not working and giving the error as yiibaseInvalidRouteException: Unable to resolve the request
where did we made wrong, why defaultroute
is working and other action in same controller is not working. Please suggest us in right way.
Advertisement
Answer
when the action name is in lowercase, working but if we get any capitals in the action name doesn’t works. like actionContactmenu works where as actionContactMenu is doesn’t working what is the reason for it let us know….
For this you have to call it contact-menu and not contactmenu.