0

我正在尝试将功能性 ZF 应用程序转换为使用 SSL。证书有效且有效,但我在配置应用程序时遇到问题。

这是 .htaccess 中的内容:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

SetEnv APPLICATION_ENV development

IndexController 非常简单:

class IndexController extends Zend_Controller_Action
{
    public function indexAction() {
      $auth = Zend_Auth::getInstance();
      if ($auth->hasIdentity()) {
        $this->_helper->redirector('index', 'dash');
      } else {
        $this->_helper->redirector('index', 'auth');
      }
    }

}

当我在没有指定 https 或端口的情况下浏览该站点时,它会准确地将我路由到https://app-url.com,但随后会尝试重定向到https://app-url.com/auth并返回 403。什么我失踪了吗?

4

1 回答 1

1

假设“index”是控制器的名称,“dash”是操作的名称,那么Redirector Helper 1的参数顺序错误。

第一个参数是动作,第二个是控制器。所以正确的方法调用是

$this->_helper->redirector('dash', 'index');

如果没有设置特定的路由,这会将您重定向到 URL /index/dash。

如果 'dash' 确实是控制器的名称,而 'index' 是动作的名称,只需添加一个名为的新控制器DashController,其中包含一个indexAction()方法并且重定向应该可以工作。

1) 如果您通过 $this->_helper->name 调用帮助程序,这将调用 direct() 方法,该方法在重定向器帮助程序中调用该方法gotoSimple($action, $controller = null, $module = null, array $params = array())

于 2012-07-31T16:25:55.730 回答