D
D
des1roer2017-05-30 18:54:44
Yii
des1roer, 2017-05-30 18:54:44

Yii2 how to configure htaccess?

Suppose I have a free hosting and I need to transfer from yii2basic to yii2basic/web
here is the following config

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
</IfModule>

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/.*
    RewriteRule ^(.*)$ yii2basic/web/$1 [L]

    RewriteCond %{REQUEST_URI} !^/yii2basic/web/
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ yii2basic/web/index.php
</IfModule>

i get that my app is available at xxx.beget.tech and i need xxx.beget.tech/yii2basic

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-05-30
@slo_nik

Good evening.
At the root of the site .htaccess

<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 directory
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

In the configuration, remove the comment from the urlManager section and write your own rules.
For default pages that are created when a project is deployed, the URLs will be without web.
If the project is in a subdirectory, then in the request section of the configuration file, write
'baseUrl' => '/yii2basic'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question