H
H
hollanditkzn2018-01-30 16:15:00
Yii
hollanditkzn, 2018-01-30 16:15:00

How do I make the url backend a separate link?

I have a question, how should I write apache so that there are 2 links /for the frontend and /backendfor the backend
Here I tried to do something like this

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
</IfModule>
 
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/.*
    RewriteRule ^(.*)$ frontend/web/$1 [L]

    RewriteCond %{REQUEST_URI} ^/backend
    RewriteRule ^(.*)$ backend/web/$1 [L]

    RewriteCond %{REQUEST_URI} !^frontend/web/
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ frontend/web/index.php
</IfModule>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-01-30
@hollanditkzn

Good afternoon.
To do this, you need to use two .htaccess, one in the root of the project, the second in the web.
In the web directory (frontend and backend), this .htaccess is enough

RewriteEngine on

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

RewriteRule . index.php

At the root of the project, .htaccess should have the following content:
RewriteEngine On

# End the processing, if a rewrite already occurred
#RewriteRule ^(frontend|backend)/web/ - [L]

# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteCond %{REQUEST_URI} ^/(name_folder/backend)
RewriteRule ^backend(/.*)?$ backend/web/$1 [L]

# handle the case of frontend
RewriteCond %{REQUEST_URI} ^/(name_folder)
RewriteRule ^(.*)$ frontend/web/$1 [L]

name_folder- directory name, if the project is located in the subdirectory of the site.
ps
By the way, I forgot to clarify. Do you have a basic template or an advanced one? I gave examples of htaccess for advanced. And if you have basic, then it is solved through modules, as Lentyuy suggested.
Modules are a little different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question