Answer the question
In order to leave comments, you need to log in
How to write a rule to change the link to the admin page?
Hello! On yii2 basic, the admin is located in a separate module and is available at mysite.loc/web/login and mysite.loc/web/site/login. I would like the admin panel to be available at mysite.loc/admin.
Can you please tell me where and how to set it up? Or in .htaccess or in urlManager?
Admin is implemented as a module:
....
modules
-admin
--controllers
--models
...
web
views
...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'<action>'=>'site/<action>',
'admin' => 'site/login',
],
],
<IfModule mod_rewrite.c>
Options +FollowSymlinks
IndexIgnore */*
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>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Answer the question
In order to leave comments, you need to log in
You need to:
1. Get rid of the web in the address, how to do this, you can google information on this topic is full
2. Register the url rule in the url manager, ala:
[
// ...
'admin' => 'site/login',
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question