PHPackages                             samsonasik/redirect-handler-module - 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. samsonasik/redirect-handler-module

ActiveLibrary[HTTP &amp; Networking](/categories/http)

samsonasik/redirect-handler-module
==================================

Laminas module to for Url Redirect handling

3.0.0(6y ago)4285MITPHPPHP ^7.1

Since Oct 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/samsonasik/RedirectHandlerModule)[ Packagist](https://packagist.org/packages/samsonasik/redirect-handler-module)[ Docs](https://github.com/samsonasik/RedirectHandlerModule)[ RSS](/packages/samsonasik-redirect-handler-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (36)Used By (0)

RedirectHandlerModule
=====================

[](#redirecthandlermodule)

[![PHP version](https://camo.githubusercontent.com/a87f90772588ce0ba825c79b8c69bb63b636c3ea14b0ba9a448a78a11c8939d0/68747470733a2f2f62616467652e667572792e696f2f70682f73616d736f6e6173696b25324672656469726563742d68616e646c65722d6d6f64756c652e737667)](https://badge.fury.io/ph/samsonasik%2Fredirect-handler-module)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/91e1b87320508cafff56c21785561e480d94d7e49851e749ba3faba3c487e004/68747470733a2f2f7472617669732d63692e6f72672f73616d736f6e6173696b2f526564697265637448616e646c65724d6f64756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/samsonasik/RedirectHandlerModule)[![Coverage Status](https://camo.githubusercontent.com/f354a6ffb9b7f81cf14a2ba1db85d1b64bf43230697a8e1ff89cec4aa4d90de7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f73616d736f6e6173696b2f526564697265637448616e646c65724d6f64756c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/samsonasik/RedirectHandlerModule)[![Downloads](https://camo.githubusercontent.com/dedcb7a0ac0fdf465de48b4ff739f6d98a1e5310cdc629b0fe3fb4c0b5cbcd32/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6173696b2f72656469726563742d68616e646c65722d6d6f64756c652f646f776e6c6f616473)](https://packagist.org/packages/samsonasik/redirect-handler-module)

*RedirectHandlerModule* is a module for handling redirect when the given url to redirect plugin is not registered in your Laminas application. It simply override existing Laminas redirect plugin, so we can just use it.

> This is README for version ^3.0 which only support Laminas 3 with php ^7.1.

> For version 2, you can read at [version 2 readme](https://github.com/samsonasik/RedirectHandlerModule/tree/2.x.x) which still support ZF3 with php ^7.1 support.

> For version 1, you can read at [version 1 readme](https://github.com/samsonasik/RedirectHandlerModule/tree/1.x.x) which still support ZF2 with php ^5.6|^7.0 support.

For example, we use `redirect()` plugin in your controller:

```
$redirect = '/foo'; // may be a variable from GET
return $this->redirect()->toUrl($redirect);
```

if the passed `$redirect` as url is a valid and registered in the routes, it uses default `redirect()` implementation, otherwise, it will redirect to default `default_url` registered in `config/autoload/redirect-handler-module.local.php`:

For example, we define:

```
return [
    'redirect_handler_module' => [
        'allow_not_routed_url' => false,
        'default_url' => '/',
        'options' => [
            'exclude_urls' => [
                // 'https://www.github.com/samsonasik/RedirectHandlerModule',
            ], // to allow excluded urls to always be redirected
            'exclude_hosts' => [
                // 'www.github.com'
            ],
        ],
    ],
];
```

It means, we can't allow to make redirect to outside registered routes, whenever found un-registered url in routes, then we will be redirected to default\_url. It also disable redirect to self, so you can't redirect to self.

For specific urls that exceptional ( allowed to be redirected even not registered in routes), you can register at `exclude_urls`/`exclude_hosts` options.

> if you define exclude\_urls/exclude\_hosts options, which one of them is your own current url/host/domain, its your risk to still get "infinite" redirection loops. so, make sure exclude\_urls/exclude\_hosts is not your current own.

While default implementation of redirect to self will silently, you can trigger your listener to handle redirect to self in your `Module::onBootstrap($e)`:

```
class Module
{
    public function onBootstrap($e)
    {
        $app           = $e->getApplication();
        $eventManager  = $app->getEventManager();
        $sharedManager = $eventManager->getSharedManager();

        $sharedManager->attach('RedirectHandlerModule\Controller\Plugin\Redirect', 'redirect-same-url', function() {
            die('You need to use different URL for Redirect');
        });

        $plugin = $app->getServiceManager()->get('ControllerPluginManager')->get('redirect');
        $plugin->setEventManager($eventManager);
    }
}
```

Installation
------------

[](#installation)

Require via composer

```
composer require samsonasik/redirect-handler-module
```

After composer require done, you can copy `vendor/samsonasik/redirect-handler-module/config/redirect-handler-module.local.php.dist` to `config/autoload/redirect-handler-module.local.php` and modify on your needs.

Last, register to `config/application.config.php`:

```
return [
    'modules' => [
        // ...
        'RedirectHandlerModule',
    ],
];
```

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

[](#contributing)

Contributions are very welcome. Please read [CONTRIBUTING.md](https://github.com/samsonasik/RedirectHandlerModule/blob/master/CONTRIBUTING.md)

Credit
------

[](#credit)

- [Abdul Malik Ikhsan](https://github.com/samsonasik)
- [All RedirectHandlerModule contributors](https://github.com/samsonasik/RedirectHandlerModule/contributors)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 98.7% 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

Every ~45 days

Recently: every ~165 days

Total

35

Last Release

2323d ago

Major Versions

0.3.0 → 1.0.02016-03-05

1.x-dev → 2.0.02018-03-18

2.x-dev → 3.0.02020-01-07

PHP version history (6 changes)0.0.1PHP &gt;=5.3.23

0.1.0PHP ^5.3.23|^7.0

0.3.0PHP ^5.4|^7.0

1.0.0PHP ^5.5|^7.0

1.5.0PHP ^5.6|^7.0

2.0.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/19076b7688ca1c8ee79ab3ac6fa6acdd7b96012973aba3b1a06cbb3154d7f3e5?d=identicon)[samsonasik](/maintainers/samsonasik)

---

Top Contributors

[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (156 commits)")[![stanimirdim92](https://avatars.githubusercontent.com/u/42135030?v=4)](https://github.com/stanimirdim92 "stanimirdim92 (2 commits)")

---

Tags

handlerlaminasredirectredirect-pluginredirectorzf2zf3handlerredirectlaminas3laminas2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samsonasik-redirect-handler-module/health.svg)

```
[![Health](https://phpackages.com/badges/samsonasik-redirect-handler-module/health.svg)](https://phpackages.com/packages/samsonasik-redirect-handler-module)
```

###  Alternatives

[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43417.4M104](/packages/kevinrob-guzzle-cache-middleware)[psr/http-server-handler

Common interface for HTTP server-side request handler

177101.3M921](/packages/psr-http-server-handler)[san/san-session-toolbar

Laminas Session Toolbar for Laminas\\DeveloperTools

39399.0k5](/packages/san-san-session-toolbar)[middlewares/request-handler

Middleware to execute request handlers

451.6M26](/packages/middlewares-request-handler)[nystudio107/craft-retour

Retour allows you to intelligently redirect legacy URLs, so that you don't lose SEO value when rebuilding &amp; restructuring a website

40975.2k15](/packages/nystudio107-craft-retour)[fsasvari/laravel-trailing-slash

The package that adds redirection with trailing slash to Laravel framework.

63164.3k](/packages/fsasvari-laravel-trailing-slash)

PHPackages © 2026

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