Answer the question
In order to leave comments, you need to log in
How to redirect from /site/index to / in yii2?
How to redirect via htaccess file from /site/index to / ?
Example.com/site/index - should lead to a redirect to example.com
If possible, give an example of
my urlmanager
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
'' => 'site/index',
'<slug>' => 'site/category',
'<category_slug>/<page_slug>' => 'site/page'
],
],
<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>
Answer the question
In order to leave comments, you need to log in
Why a redirect? It is just necessary that site / index does not appear in the project
'rules' => [
'/' => 'site/index',
]
Url::toRoute(['site/index']) //будет генерить '/'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question