Q:

How to stop loop redirection in ZF2 Module

What I am trying to do is to redirect onBootstrap inside a Module.php.
I have this code:
$response = $e->getResponse();
        $response->setHeaders( $response->getHeaders()->addHeaderLine('Location', 'google.com'));
        $response->setStatusCode($response::STATUS_CODE_301);
        $response->sendHeaders();
        exit;

This code returns redirect loop. Does anyone know what am I doing wrong?
EDITED:
this code appends google.com behind the baseroot. How can I redirect to different page?

A:

The Location header must contain either a valid URL or an absolute path. Your header line should be:
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', 'http://www.google.com'));

Also, you shouldn't really call exit; in a ZF application. See the answer here for the correct way to end execution.

