Q: Yii2 Trailing slash always appear on home URL Trailing slash always appear on home URL ( www.test.com/ ). 
Even after typing the normal url like www.test.com, it is redirected to www.test.com/
Here is my url config:
'urlManager' => [
        'class' => 'yii\web\UrlManager',
        'showScriptName' => false,
        'enablePrettyUrl' => true,
        'rules' => [

                   ...

                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

                ],
    ],

Here is the .htaccess file:
RewriteEngine on

# 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

I would like the home page to be loaded like this ( www.test.com ) and to be redirected to www.test.com even when the user type www.test.com/ in the url

A: To remove a trailing slash using .htaccess you can just use:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]

Make sure you clear your cache before testing this, but should work without issue.
EDIT:
RewriteCond %{THE_REQUEST} //
RewriteRule .* $0 [R]

