我遵循了以下教程:Yii 1.1: URL management for Websites with secure and nonsecure pages
这是来自/protected/config/main.php
'urlManager'=>array(
'class' => 'UrlManager',
'hostInfo' => 'http://goliv.me',
'secureHostInfo' => 'https://goliv.me',
'secureRoutes' => array(
'site/booking', // site/login action
),
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'urlSuffix' => '.html',
'rules' => array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>'
),
),
和我的.htaccess
文件:
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
我只对site/booking
:
此网页有重定向循环
当我删除此部分时:
'secureRoutes' => array(
'site/booking'
),
一切都没有问题。
任何解决方案?
答案 0 :(得分:0)
如果路径末尾有斜杠,则Method不会更正返回true,因此调用site / booking /将不会返回true。
class UrlManager extends CUrlManager
{
................
/**
* @param string the URL route to be checked
* @return boolean if the give route should be serviced in SSL mode
*/
protected function isSecureRoute($route)
{
if ($this->_secureMap === null) {
foreach ($this->secureRoutes as $r) {
$this->_secureMap[strtolower($r)] = true;
}
}
$route = strtolower($route);
if (isset($this->_secureMap[$route])) {
return true;
} else {
return ($pos = strpos($route, '/')) !== false
&& isset($this->_secureMap[substr($route, 0, $pos)]);
}
}