# How do I redirect a response?

Sometimes you may wish to redirect the user to another location, either to an external site or within the store. To do so, pass the URL, `route()`, or an `Illuminate\Http\RedirectResponse` instance to the `setRedirect()` method.

For example, if you stored the age of customers (computed from their provided date of birth), and needed to prevent access to those under the age of 18:

```php
\Aero\Store\Http\Responses\ProductPage::extend(function (\Aero\Store\Http\Responses\ProductPage $page, \Closure $next) {
    if ($page->request->customer()->age < 18) {
        $page->setRedirect('/denied');
    }

    return $next($page);
});
```

As extension code is evaluated in the order it's added to the response builder, code that runs after this step may override the redirect.

To force a redirect and prevent execution of the code that follows in the pipeline, you should return an instance of the `redirect()` helper:

```php
\Aero\Store\Http\Responses\ProductPage::extend(function (\Aero\Store\Http\Responses\ProductPage $page, \Closure $next) {
    if (! $page->product->canBeViewedByIp($page->request->ip())) {
        return redirect('/denied');
    }

    return $next($page);
});
```