PHPackages                             hiraeth/middleware-browser-redirect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. hiraeth/middleware-browser-redirect

ActiveOpus-package[HTTP &amp; Networking](/categories/http)

hiraeth/middleware-browser-redirect
===================================

Redirect browsers / versions to alternative URLs

2.0.0(3y ago)07.0k—7.4%MITPHP

Since Nov 4Pushed 2y agoCompare

[ Source](https://github.com/hiraeth-php/middleware-browser-redirect)[ Packagist](https://packagist.org/packages/hiraeth/middleware-browser-redirect)[ RSS](/packages/hiraeth-middleware-browser-redirect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

This is a PSR-15 middleware that can be configured with a series of rules to detect specific browsers, versions, and request paths and redirect them to an alternate URL.

Basic Usage
-----------

[](#basic-usage)

```
//
// The factory must be an actual instance of a response factory, the PSR interface here is
// used as a stand in for any particular PSR compatible implementation.
//

$factory  = new Psr\Http\Message\ResponseFactoryInterface();
$browser  = new Sinergi\BrowserDetector\Browser();
$redirect = new BrowserRedirect($browser, $factory);

$redirect->addRule([
	'target'   => '/.*',
	'browser'  => 'IE',
	'version'  => 'process($request, $handler);
```

Hiraeth Integration
-------------------

[](#hiraeth-integration)

1. Package configuration and middleware configuration will be copied on install
2. Additional rules can be added to any config as an array of objects:

```
[browser]

	rules = [
		{
			"target": "/.*",
			"browser": "IE",
			"version": "
