How to redirect non-zend link from zend app

My application is a mixture of simple PHP web pages and a zend application. Someday I need to redirect to a simple PHP web page from a zend application application.

For instance:

I want to redirect from example.com/module/controller/actionto example.com/simplephp.php.

I tried header("Location: example.com/simplephp.php");, but it does not work.

thank

+3
source share
3 answers

Yes, the main redirect action helper allows you to redirect to any URL.

class MyController extends Zend_Controller_Action {
    public function indexAction() {

        $this->_redirect('/path/to/any/page.php');
        // or
        $this->_redirect('http://example.com/anypage.php');
    }
}
+9
source

HTTP / 1.1 requires an absolute URI as an argument. The request must contain http://eitherhttps://

+3
source

request, HTTP.

:

header("Location: example.com/simplephp.php");

:

$request->setHeader('Location', 'example.com/simplephp.php', true);

, , ..

An easy way to handle redirects without worrying about the details is through the Redirector action helper . You can use it even outside the controller, getting its static instance from Helper Broker.

Please note that even if shortened URLs work in almost all browsers, you should always provide the full URL for the location (including protocol and domain name) as specified in HTTP 1.1.

+1
source

Source: https://habr.com/ru/post/1774459/


All Articles