Answer the question
In order to leave comments, you need to log in
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
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>
# 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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question