Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Zend 301重定向-一些神秘的不工作?_Php_Zend Framework_Redirect - Fatal编程技术网

Php Zend 301重定向-一些神秘的不工作?

Php Zend 301重定向-一些神秘的不工作?,php,zend-framework,redirect,Php,Zend Framework,Redirect,我有一个问题,其中一些重定向不工作,一些是。我使用的是一种粗略的重定向方法,即捕获ErrorController的errorAction中的url,然后使用一些if语句,然后按如下方式进行重定向: public function errorAction() { $request = basename($this->getRequest()->getRequestUri()); $this->getHelper('redirector')

我有一个问题,其中一些重定向不工作,一些是。我使用的是一种粗略的重定向方法,即捕获
ErrorController
errorAction
中的url,然后使用一些if语句,然后按如下方式进行重定向:

 public function errorAction()
    {
        $request = basename($this->getRequest()->getRequestUri());
        $this->getHelper('redirector')->setCode(301);
        if ($request == 'rand.html')
            $this->_redirect('/services/currency/rand');
        if ($request == 'dollar.html')
            $this->_redirect('/services/currency/dollar');
        if ($request == 'zim-dollar-currency.html')
            $this->_redirect('/services/currency/zim');

        //About 20 of these If statements

        $errors = $this->_getParam('error_handler');

        //load appearance stuff

        if (!$errors) {
            $this->view->message = 'You have reached the error page';
            return;
        }

        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $priority = Zend_Log::NOTICE;
                $this->view->message = 'Page not found';
                $this->view->headTitle()->prepend('Page Not Found');
                break;
            default:
                // application error
                $this->getResponse()->setHttpResponseCode(500);
                $priority = Zend_Log::CRIT;
                $this->view->message = 'Application error';
                $this->view->headTitle()->prepend('Application error');
                break;
        }

        $this->view->request = $errors->request;
    }
所以,有些有效,有些无效,比如:津巴布韦元货币


不知道为什么会这样。我甚至检查过windows行结尾等内容。没有…

尝试使用默认操作的构造

您是否对不起作用的URL执行了
$request
var\u dump
?它是进入这个控制器/动作还是在其他地方处理?vardump给出:string(22)“rand.html”,string(18)“zim.html”等等