{"id":15307503,"url":"https://github.com/samsonasik/redirecthandlermodule","last_synced_at":"2025-06-27T23:04:50.188Z","repository":{"id":62539899,"uuid":"44771720","full_name":"samsonasik/RedirectHandlerModule","owner":"samsonasik","description":":leftwards_arrow_with_hook: Zend Framework/Laminas Module for Redirect with Handling against url","archived":false,"fork":false,"pushed_at":"2020-01-07T17:04:41.000Z","size":430,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T00:55:20.399Z","etag":null,"topics":["handler","laminas","redirect","redirect-plugin","redirector","zf2","zf3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samsonasik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://samsonasik.wordpress.com/donate/"}},"created_at":"2015-10-22T20:35:00.000Z","updated_at":"2022-04-25T12:45:44.000Z","dependencies_parsed_at":"2022-11-02T15:32:11.287Z","dependency_job_id":null,"html_url":"https://github.com/samsonasik/RedirectHandlerModule","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/samsonasik/RedirectHandlerModule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsonasik%2FRedirectHandlerModule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsonasik%2FRedirectHandlerModule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsonasik%2FRedirectHandlerModule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsonasik%2FRedirectHandlerModule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samsonasik","download_url":"https://codeload.github.com/samsonasik/RedirectHandlerModule/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsonasik%2FRedirectHandlerModule/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262347476,"owners_count":23296894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["handler","laminas","redirect","redirect-plugin","redirector","zf2","zf3"],"created_at":"2024-10-01T08:10:28.006Z","updated_at":"2025-06-27T23:04:50.170Z","avatar_url":"https://github.com/samsonasik.png","language":"PHP","funding_links":["https://samsonasik.wordpress.com/donate/"],"categories":[],"sub_categories":[],"readme":"RedirectHandlerModule\n=====================\n\n[![PHP version](https://badge.fury.io/ph/samsonasik%2Fredirect-handler-module.svg)](https://badge.fury.io/ph/samsonasik%2Fredirect-handler-module)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://travis-ci.org/samsonasik/RedirectHandlerModule.svg?branch=master)](https://travis-ci.org/samsonasik/RedirectHandlerModule)\n[![Coverage Status](https://coveralls.io/repos/samsonasik/RedirectHandlerModule/badge.svg?branch=master)](https://coveralls.io/r/samsonasik/RedirectHandlerModule)\n[![Downloads](https://poser.pugx.org/samsonasik/redirect-handler-module/downloads)](https://packagist.org/packages/samsonasik/redirect-handler-module)\n\n*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.\n\n\u003e This is README for version ^3.0 which only support Laminas 3 with php ^7.1.\n\n\u003e 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.\n\n\u003e 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.\n\nFor example, we use `redirect()` plugin in your controller:\n\n```php\n$redirect = '/foo'; // may be a variable from GET\nreturn $this-\u003eredirect()-\u003etoUrl($redirect);\n```\n\nif 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`:\n\nFor example, we define:\n\n```php\nreturn [\n    'redirect_handler_module' =\u003e [\n        'allow_not_routed_url' =\u003e false,\n        'default_url' =\u003e '/',\n        'options' =\u003e [\n            'exclude_urls' =\u003e [\n                // 'https://www.github.com/samsonasik/RedirectHandlerModule',\n            ], // to allow excluded urls to always be redirected\n            'exclude_hosts' =\u003e [\n                // 'www.github.com'\n            ],\n        ],\n    ],\n];\n```\n\nIt 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.\n\nFor specific urls that exceptional ( allowed to be redirected even not registered in routes), you can register at `exclude_urls`/`exclude_hosts` options.\n\n\u003e 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.\n\nWhile default implementation of redirect to self will silently, you can trigger your listener to handle redirect to self in your `Module::onBootstrap($e)`:\n\n```php\nclass Module\n{\n    public function onBootstrap($e)\n    {\n        $app           = $e-\u003egetApplication();\n        $eventManager  = $app-\u003egetEventManager();\n        $sharedManager = $eventManager-\u003egetSharedManager();\n\n        $sharedManager-\u003eattach('RedirectHandlerModule\\Controller\\Plugin\\Redirect', 'redirect-same-url', function() {\n            die('You need to use different URL for Redirect');\n        });\n\n        $plugin = $app-\u003egetServiceManager()-\u003eget('ControllerPluginManager')-\u003eget('redirect');\n        $plugin-\u003esetEventManager($eventManager);\n    }\n}\n```\n\nInstallation\n------------\n\nRequire via composer\n```bash\ncomposer require samsonasik/redirect-handler-module\n```\n\nAfter 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.\n\nLast, register to `config/application.config.php`:\n\n```php\nreturn [\n    'modules' =\u003e [\n        // ...\n        'RedirectHandlerModule',\n    ],\n];\n```\n\nContributing\n------------\nContributions are very welcome. Please read [CONTRIBUTING.md](https://github.com/samsonasik/RedirectHandlerModule/blob/master/CONTRIBUTING.md)\n\nCredit\n------\n\n- [Abdul Malik Ikhsan](https://github.com/samsonasik)\n- [All RedirectHandlerModule contributors](https://github.com/samsonasik/RedirectHandlerModule/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsonasik%2Fredirecthandlermodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamsonasik%2Fredirecthandlermodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsonasik%2Fredirecthandlermodule/lists"}