F
F
First Name2018-06-04 09:04:43
Yii
First Name, 2018-06-04 09:04:43

How to properly configure routing on Yii 2 on apache server?

Good day to all.
Terribly stupid question, but still.
There is a standard controller (SiteController) which has a Login action.
Apache 2.4 is installed on the local server (OSPanel), everything works fine, uploaded to the server, gives a 404 error.
.htaccess file in /web folder only

RewriteEngine On RewriteBase /

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

RewriteRule . index.php

The action itself is standard
public function actionLogin()
    {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }
        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->goBack();
        }
        $model->password = '';
        return $this->render('login', [
            'model' => $model,
        ]);
    }

Setting UrlManager in config/web.php is the most standard
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
//                ''=>'site/index',
//                '<action>'=>'site/<action>',
            ],
        ],

Should work on the site.ru/site/login route.
Thank you in advance for your help :)
PS Do not throw slippers

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lander, 2018-06-04
@usdglander

So, what doesn't work? Does site.ru itself work?

D
Dmitry Kim, 2018-06-04
@kimono

index.phpDid you by any chance forget the file itself ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question