E
E
Evgenya-k22019-04-15 09:28:42
Yii
Evgenya-k2, 2019-04-15 09:28:42

How to set up a redirect in the backend / web to the address admin on the hosting?

Good afternoon.
I am deploying a site on a hosting (advanced template), backend should open at /admin.
.htacess at the root of the site:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin\/?(.*) /backend/web/$1
 
RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|admin)
RewriteRule (.*) /frontend/web/$1
 
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /frontend/web/index.php
 
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /backend/web/index.php

On hosting, from the public_html folder, a symbolic link to frontend/web, from frontend/web, a symbolic link admin to backend/web.
When trying to go to my-cite/admin, it gives 404, and my-cite/backend/web appears in the URL. What could be wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Moses Fender, 2019-04-15
@Evgenya-k2

/backend/web/index.php
You can't use .htaccess on the backend this way.

F
Fedor Grebennikov, 2019-04-15
@grebennikovf

Part of htaccess from the working project on the advanced template, where the admin panel is located at /admin:

Options +SymlinksIfOwnerMatch
IndexIgnore */*
RewriteEngine On

# Если запрос начинается с /admin, то заменяем на /backend/web/
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin\/?(.*) /backend/web/$1

RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|admin)
RewriteRule (.*) /frontend/web/$1

# Если frontend запрос
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /frontend/web/index.php

# Если backend запрос
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /backend/web/index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question