Answer the question
In order to leave comments, you need to log in
Yii2 controller action and file?
Hello.
The following problem has arisen:
Suppose there is the following controller call:
users/getphoto/111/400x300.jpg , the action is transferred to the controller, it generates a file and gives it to the client as an image.
Now, what I want to do is create a file right after generating users/getphoto/111/400x300.jpg , so that the client can access the file right away. Everything seems to be ok, but!
the following paths:
users/
users/getphoto - give a 403 error, forbidding viewing the contents of the folder, and are not sent to the controller.
How to change .htaccess so that users/ and users/getphoto are sent to index.php?
Now I have this code:
#Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#otherwise forward it to index.php
#RewriteRule . index.php
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
RewriteRule ^(users)$ index.php/$1 [L,QSA]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question