T
T
T3R3AND2021-10-11 17:18:46
Yii
T3R3AND, 2021-10-11 17:18:46

Is it possible and how to remove web from yii2 address bar?

Hello! Question in the header, 301 redirect. Yii2 basic. At the moment these rules are:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Bay, 2021-10-11
@kawabanga

Make a webroot of the web folder.

V
vitaly_74, 2021-10-16
@vitaly_74

at the root of the project there is .htaccess in it I have written:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
</IfModule>

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/(assets|css|js|images|storage)
    RewriteRule ^assets/(.*)$ backend/web/assets/$1 [L]
    RewriteRule ^css/(.*)$ backend/web/css/$1 [L]
    RewriteRule ^js/(.*)$ backend/web/js/$1 [L]
    RewriteRule ^images/(.*)$ backend/web/images/$1 [L]
    RewriteRule ^storage/(.*)$ backend/web/storage/$1 [L]
    RewriteRule ^(.*)$ backend/web/$1 [L]

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

in the web folder there is also .htaccess in it I write
# use mod_rewrite for pretty URL support
Options -Indexes
RewriteEngine on
# If a directory or a file exists, use the request directly
#RewriteCond %{REQUEST_URI} ^/(storage)
#RewriteRule ^/storage/(.*)/documents/(.*)$ /storage/db/documents/$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php

link to article
https://xn--d1acnqm.xn--j1amh/%D0%B7%D0%B0%D0%BF%D...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question