On the server there is a user folder, in it there is a folder with the domain of the future site, for example site.com .

I put composer in the user’s folder and say when installing the framework into the site.com folder. It is placed and I see that index.php and robots.txt not in site.com but in site.com/web you have to reconfigure the web server now so that it looks in another folder? namely site.com/web ?

  • yes, that's it you need to put htaccess with redirection in the root of the site, as well as in the web folder ....... an example is here: ru.stackoverflow.com/a/517861/191482 - Alexey Shimansky
  • @ Aleksey-Shimansky thanks, it helped, as the answer would have been done - RoboNoob
  • I can only close as a duplicate: D - Alexey Shimansky
  • @ Alexey-Shimansky can of course)) Just that question has such a complicated name and it wasn’t on the list of similar ones - RoboNoob
  • If there is a proposal for a lighter headline, I will only be glad because I suffered what to write - Alexey Shimansky

1 answer 1

Yes, you have noticed everything correctly: you need to put the .htaccess file with redirection in the root of the site, as well as in the web folder:

At the root of the site:

 <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On </IfModule> <IfModule mod_rewrite.c> RewriteCond %{REQUEST_URI} ^/.* RewriteRule ^(.*)$ web/$1 [L] RewriteCond %{REQUEST_URI} !^/web/ RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ web/index.php </IfModule> 

In the web folder:

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

The default configuration of routing yii2 , including the htaccess configuration, can be found in the yii2 branch, namely in this answer.