O
O
oe24y2016-02-22 11:41:49
Yii
oe24y, 2016-02-22 11:41:49

Yii2: Made a prettyUrl and the site doesn't open the Login page by default. How to fix?

At the address localhost/web , everything opens normally - a template site from the Yii2 archive ActionLogin should open at the
address localhost/web/login , but instead - Object not found! (404)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2016-02-22
@oe24y

huh localhost/web/site/login?
Do you have login in the routes?

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'contact' => 'site/contact',
                'about' => 'site/about',
                'login' => 'site/login',
            ],

The web/.htaccess file must contain:
Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

If it doesn't exist, then you need to create it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question