使用时
Yii::app()->createUrl('/page/');
它正在向 URL LIKE http://www.sitename// AND http://www.sitename//page添加额外的斜杠
我需要排除两个斜杠,应用程序 url 管理器如下,
'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 规则
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]