P
P
Pepper12017-03-17 00:47:25
Yii
Pepper1, 2017-03-17 00:47:25

UrlManager stopped working in Yii2. Where to look for an error?

UrlManager stopped working in Yii2. Where to look for an error?
The debugger gives:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "login".' in Z:\home\yii.one\www\vendor\yiisoft\yii2\base\Module.php:462 Stack trace: #0 Z:\home\yii.one\www\vendor\yiisoft\yii2\web\Application .php(100): yii\base\Module->runAction('login', Array) #1 Z:\home\yii.one\www\vendor\yiisoft\yii2\base\Application.php(375): yii \web\Application->handleRequest(Object(yii\web\Request)) #2 Z:\home\yii.one\www\index.php(12): yii\base\Application->run() #3 { main} Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in Z:\home\yii.one\www\vendor\yiisoft\yii2\web\Application.php:112 Stack trace: #0 Z:\home\yii.one\www\vendor\yiisoft\yii2\base\Application .php(375): yii\web\Application->handleRequest(Object(yii\web\Request)) #1 Z:
Tell me where to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-03-17
@slo_nik

In web/.htaccess

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

To the root of the site .htaccess
<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine on
</IfModule>

<IfModule mod_rewrite.c>
   RewriteCond %{REQUEST_URI} ^/.*
   RewriteRule ^(.*)$ web/$1 [L]

   RewriteCond %{REQUEST_URI} !^/web/
   RewriteCond %{REQUEST_FILENAME} !-f [OR]
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^.*$ web/index.php

</IfModule>

In urlManager
UrlManager:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
],

The site should open at site.com (main page), web is removed from the address.
If the action is in the SiteController controller, then add
the login form to the urlManager at site.com/login
You may also need to specify 'loginUrl' in the configuration
Example (specify your own data and paths)
'user' => [
            //'identityClass' => 'app\modules\users\models\Users',
            'identityClass' => app\modules\users\models\Users::className(),
            'enableAutoLogin' => true,
            'loginUrl' => ['users/default/login']
        ],

P
Pepper1, 2017-03-18
@Pepper1

Issue resolved. I screwed up with the config/web. Updated - everything worked...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question