A
A
AlexAll2019-01-04 19:06:00
Yii
AlexAll, 2019-01-04 19:06:00

How in yii2 to make the admin panel not open by /backend/web/index.php?

I use this htaccess to open the admin panel at the link site.ru/admin


Options +FollowSymlinks
RewriteEngine On
# deal with admin first
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.* )$ backend/web/css/$1 [L]
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^.*$ backend/web/index .php [L]
RewriteCond %{REQUEST_URI} ^/(assets|css|js|images)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend /web/css/$1 [L]
RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]
RewriteRule ^images/(.*)$ frontend/web/images/$1 [L]
RewriteRule ^( .*)$ frontend/web/$1 [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule ^.*$ frontend/web/index.php

in the backend
# If it's a folder or file, open it
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise, redirect to index.php
RewriteRule . index.php

but if you try to enter backend/web/index.php, then it also opens, how to make it give 404 at this address and lead to the admin panel at site.ru/admin?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-01-04
@webinar

How in yii2 to make the admin panel not open by /backend/web/index.php?

shut down the server
What does yii have to do with it and why not just redirect to site.ru/admin instead of 404

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question