Answer the question
In order to leave comments, you need to log in
How to set up .htaccess in yii2 so that you can open the root folder from the browser?
There is such piece .htaccess. Tried adding "RewriteCond %{REQUEST_URI} !^/new/" , i.e. exclude /new/ from the redirect rule, but doesn't work.
As I understand it, it redirects everything to index.php. At the root of the site (next to .htaccess) is the new folder, which contains index.php. It is necessary that when you enter sitename.ru/new/, the new folder opens.
<IfModule mod_rewrite.c>
# remove slash
RewriteCond %{THE_REQUEST} \s/+(.+?)/+[?\s]
RewriteRule /$ /%1 [R,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
#Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# если /admin, то в backend
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
RewriteRule ^admin/js/(.*)$ backend/web/js/$1 [L]
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|js|css|js)/
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
</IfModule>
Answer the question
In order to leave comments, you need to log in
Tried adding "RewriteCond %{REQUEST_URI} !^/new/"
/new/
.# remove slash
RewriteCond %{THE_REQUEST} \s/+(.+?)/+[?\s]
RewriteRule /$ /%1 [R,L]
RewriteRule ^(.*)$ frontend/web/$1
RewriteRule ^new/ -
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question