A
A
AlexAll2018-11-27 12:31:40
Yii
AlexAll, 2018-11-27 12:31:40

How to properly configure htaccess in yii2 so that folders are not shown?

Hello, I created an api folder in advanced yii2 in htaccess at the root registered

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
</IfModule>
 
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/(api)
    RewriteRule ^.*$ api/web/index.php [L]
</IfModule>

created htaccess in the api folder itself and registered
# Если это папка или файл, открываем его
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# В противном случае перенаправляем на index.php
RewriteRule . index.php

But for some reason it displays folders, upon entering the site / api
5bfd0e995c17c208834480.png
For the backend, the same is written and everything works
RewriteCond %{REQUEST_URI} ^/(admin)
    RewriteRule ^.*$ backend/web/index.php [L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2018-11-27
@usdglander

Once a week, a similar question is consistently asked. This is resolved not in htaccess, but by specifying the web directory as the root for the domain!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question