A
A
Alexander Ivanov2017-10-05 09:00:08
Yii
Alexander Ivanov, 2017-10-05 09:00:08

How to set up access to files from the web in yii2?

Often there is a need for the one who manages the content to fill in the web folder, for example, robots.txt or files like yandex_439f6a0ecf66cf4e.html or Google, or statistics files that do not require programming and just need to be.
On yii2, you can currently access images and some other files from the web folder.
How to make it possible to access site.ru/yandex_439f6a0ecf66cf4e.html without creating a view and a controller ?
or
What should I change so that files with .html permission are also opened from the web?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pozdnyakov, 2017-10-05
@Afinogen

Specify the corresponding rule in .htaccess, since you did not bring your own, I cannot say what exactly to write there.
You can do something like this in the root of frontend / web

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

In this case, if no files are found on the disk, all requests will go to index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question