V
V
Vladislav Sofienko2017-10-06 10:30:27
Yii
Vladislav Sofienko, 2017-10-06 10:30:27

How to configure htaccess in Yii2 for a folder in the root of the site?

Hello. I have a Yii2 advanced project with current htaccess settings for fontend and backend

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if request begins with /admin remove admin and ad /backend/web/
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin\/?(.*) /backend/web/$1

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

# if frontend request 
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /frontend/web/index.php 

# if backend request
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /backend/web/index.php

How to set up so that I can open files in the uploads folder, which lies in the root of the project through the files line, like in backend / web through the admin line? In the uploads folder there are other folders such as doc (pdf, doc, etc.) and images
For example domain.com/files/doc/blablabla.pdf

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-10-06
@qonand

RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|admin|uploads)

RewriteCond %{REQUEST_URI} ^/uploads
RewriteRule . /files/$1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question