TED
TED

Reputation: 1839

How to remove trailing additional slash yii

When using the

Yii::app()->createUrl('/page/');

it is additing additional trailing slash to the url LIKE http://www.sitename// AND http://www.sitename//page

That I need to exclude two slashes, Application url manager is as follow,

'urlManager' => array(
        'urlFormat' => 'path',
        'showScriptName' => false,
        'urlSuffix' => '/',
        'rules' => array(
            'site/news_letter_unsubsubscribe/<id:\w+>' => 'site/news_letter_unsubsubscribe',
            'page/<id:[\w\-]+>' => 'page/index/',
            'site/blog_detail/<id:[\w\-]+>' => 'site/blog_detail',
            'location/<id:[\w\-]+>' => 'location/index',
            'auth/partner_detail/<id:[\w\-]+>' => 'auth/partner_detail',
            //'tour/tour_detail/<id:\w+>/<date:\w+>'=>'tour/tour_detail',
            'activity/activity_detail/<id:[\w\-]+>' => 'activity/activity_detail',
            'activity/compare_detail/<id:[\w\-]+>' => 'activity/compare_detail',
            'tour/tour_detail/<id:[\w\-]+>' => 'tour/tour_detail',
            'tour/compare_detail/<id:[\w\-]+>' => 'tour/compare_detail',
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
            '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            'auth/reset_password/<id:\w+>' => 'auth/reset_password',
            'site/linkedin_login/<id:\w+>' => 'site/linkedin_login',

        ),
    )

.htaccess rules

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

Upvotes: 0

Views: 1971

Answers (2)

TED
TED

Reputation: 1839

I could sort this issue removing the suffix slash from request base url

Thanks

Upvotes: 0

Fortran
Fortran

Reputation: 593

In Yii2 your code is wrong. You are reading doc! Example:

echo \Yii::$app->urlManager->createUrl('page');

Upvotes: 2

Related Questions