PHPackages                             settermjd/redirect-to-new-domain-middleware - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. settermjd/redirect-to-new-domain-middleware

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

settermjd/redirect-to-new-domain-middleware
===========================================

This is a small piece of PSR-15 (HTTP Server Request Handlers) middleware that redirects a request from one domain to a new one; such as an old one that's being deprecated to a new one when a site is being re-hosted

0.0.1(1y ago)10BSD-3-ClausePHPCI passing

Since Jan 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/settermjd/redirect-to-new-domain-middleware)[ Packagist](https://packagist.org/packages/settermjd/redirect-to-new-domain-middleware)[ Docs](https://settermjd.github.io/redirect-to-new-domain-middleware/)[ Fund](https://funding.communitybridge.org/projects/laminas-project)[ RSS](/packages/settermjd-redirect-to-new-domain-middleware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (2)Used By (0)

Redirect to new domain middleware
=================================

[](#redirect-to-new-domain-middleware)

This is a small piece of [PSR-15 (HTTP Server Request Handlers)](https://www.php-fig.org/psr/psr-15/) middleware that redirects a request from one domain to a new one; such as an old one that's being deprecated to a new one when a site is being re-hosted.

Prerequisites
-------------

[](#prerequisites)

To use the package, you'll need the following:

- PHP 8.3

Getting Started
---------------

[](#getting-started)

### With Mezzio

[](#with-mezzio)

To use the project, in a Mezzio application, you first need to provide it with the configuration that it needs. If you use RedirectToNewDomainMiddlewareFactory to instantiate it, which is the default option, it will look in [the $\_ENV superglobal](https://www.php.net/manual/en/reserved.variables.environment.php) first, then in the application's configuration array.

A sample configuration is available in *config/sample.redirecttonewdomainmiddleware.global.php*. Copy that to *config/autoload*, renaming it to *redirecttonewdomainmiddleware.global.php*. Then, update the values for the `old` and `new` keys to the required values for your application. These values are:

- **old:** The domain that is being *deprecated* or is to be redirected *from*
- **new:** The domain, which requests are to be redirected *to*

Then, for all routes that need the functionality, load the middleware as early in the route's pipeline as possible. This will ensure that the redirect happens before any other functionality is invoked. For example, in a `ConfigProvider` class, you could define a route as follows:

```
[
    'path'            => '/',
    'middleware'      => [
        Settermjd\Middleware\RedirectToNewDomainMiddleware::class,
        App\Handler\HomePageHandler::class,
    ]
    'allowed_methods' => ['GET'],
],
```

Alternatively, add the middleware to the global pipeline in config/pipeline.php as early as possible, such as in the following example:

```
$app->pipe(Settermjd\Middleware\RedirectToNewDomainMiddleware::class);
```

You should not need to do anything else, as `RedirectToNewDomainMiddleware` will be registered with the application's DI container via the package's [ConfigProvider](https://matthewsetter.com/using-configproviders/) class, which is automatically loaded when the package is installed into a Mezzio application.

Contributing
------------

[](#contributing)

If you want to contribute to the project, whether you have found issues with it or just want to improve it, here's how:

- [Issues](https://github.com/settermjd/redirect-to-new-domain-middleware/issues): ask questions and submit your feature requests, bug reports, etc
- [Pull requests](https://github.com/settermjd/redirect-to-new-domain-middleware/issues): send your improvements

Did You Find The Project Useful?
--------------------------------

[](#did-you-find-the-project-useful)

If the project was useful and you want to say thank you and/or support its active development, here's how:

- Add a GitHub Star to the project
- Write an interesting article about the project wherever you blog

Disclaimer
----------

[](#disclaimer)

No warranty expressed or implied. Software is as is.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance41

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

488d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d4c6c662daf6b4a9742c59d0a72c069633a9772c831ecc1de7a2926ee4d8d95?d=identicon)[settermjd](/maintainers/settermjd)

---

Top Contributors

[![settermjd](https://avatars.githubusercontent.com/u/196801?v=4)](https://github.com/settermjd "settermjd (24 commits)")

---

Tags

middlewarePSR-11laminaspsr-15mezzio

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/settermjd-redirect-to-new-domain-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/settermjd-redirect-to-new-domain-middleware/health.svg)](https://phpackages.com/packages/settermjd-redirect-to-new-domain-middleware)
```

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[mezzio/mezzio-skeleton

Laminas mezzio skeleton. Begin developing PSR-15 middleware applications in seconds!

12726.2k](/packages/mezzio-mezzio-skeleton)[mezzio/mezzio-swoole

Swoole support for Mezzio

92238.9k3](/packages/mezzio-mezzio-swoole)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[chubbyphp/chubbyphp-framework

A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

13544.4k4](/packages/chubbyphp-chubbyphp-framework)[elie29/zend-phpdi-config

PSR-11 PHP-DI autowire container configurator for Laminas, Mezzio, ZF2, ZF3 and Zend Expressive applications

20238.6k7](/packages/elie29-zend-phpdi-config)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
