Настраиваем ЧПУ в Yii
Вносим изменения в файл advanced/backend/config/main.php
|
1 2 3 4 5 6 7 8 9 10 11 12 |
return [ 'homeUrl' => '/admin', 'components' => [ 'request' => [ 'baseUrl' => '/admin', ], 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, ], ], ]; |
Вносим изменения в файл advanced/frontend/config/main.php
|
1 2 3 4 5 6 7 8 9 10 11 12 |
return [ 'homeUrl' => '/', 'components' => [ 'request' => [ 'baseUrl' => '', ], 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, ], ], ]; |
Создаем файл в корне сайта .htaccess
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# prevent directory listings Options -Indexes # follow symbolic links Options FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/admin/$ RewriteRule ^(admin)/$ /$1 [R=301,L] RewriteCond %{REQUEST_URI} ^/admin RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT] RewriteCond %{REQUEST_URI} ^.*$ RewriteRule ^(.*)$ /frontend/web/$1 |
Создаем advanced/frontend/web/.htaccess
Создаем advanced/backend/web/.htaccess
|
1 2 3 4 5 6 7 |
# use mod_rewrite for pretty URL support RewriteEngine on # if a directory or a file exists, use the request directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward the request to index.php RewriteRule . index.php |