PHPackages                             imos/domainredirector - 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. imos/domainredirector

AbandonedArchivedLibrary

imos/domainredirector
=====================

imos DomainRedirector to redirect incoming requests to the correct domain

v0.5(8y ago)041.6k—6.3%[1 issues](https://github.com/imosnet/domain-redirector/issues)MITPHPPHP &gt;=5.5.0

Since Dec 14Pushed 8y ago3 watchersCompare

[ Source](https://github.com/imosnet/domain-redirector)[ Packagist](https://packagist.org/packages/imos/domainredirector)[ Docs](https://www.imos.net)[ RSS](/packages/imos-domainredirector/feed)WikiDiscussions master Synced 1mo ago

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

imos/domain-redirector
======================

[](#imosdomain-redirector)

[![Build Status](https://camo.githubusercontent.com/c9faaf1d3377c85b4cf4a1ce956b2f4a36d851f6f8e7e7d31b9885e0c05898b6/68747470733a2f2f6170692e7472617669732d63692e6f72672f696d6f736e65742f646f6d61696e2d72656469726563746f722e737667)](https://travis-ci.org/imosnet/domain-redirector)

Websites sometimes have many secondary domains. To satisfy seo requirements and make it the right way, every website should only have one primary domain. This library is designed to manage the domain configuration for a site. Special feature is, that you can configure multiple primary domains (that's useful for multi-site environments).

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';
use Imos\DomainRedirector\DomainRedirector;
use Symfony\Component\HttpFoundation\Request;

// create object
$domainRedirector = new DomainRedirector();

// add primary domain and the corresponding secondary domains
$domainRedirector->addPrimaryDomain('www.imos.net', true); // second argument = ssl
$domainRedirector->addSecondaryDomain('www.imosnet.de', 'www.imos.net'); // www.imosnet.de should redirect to www.imos.net
$domainRedirector->addSecondaryDomain('www.anotherdomain.de', 'www.imos.net'); // ...

// if we have another primary domain, we could add it here
$domainRedirector->addPrimaryDomain('www.another-domain.de');
$domainRedirector->addSecondaryDomain('www.foobar.de', 'www.another-domain.de');

// we can even add a fallback, for requests that does not match any domain
$domainRedirector->setFallbackDomain('www.imos.net');

// pass a symfony request object to $domainRedirector. For example we fake some requests:

$request = Request::create('/de/test.html?x=y', 'GET', [], [], [], ['HTTP_HOST' => 'www.imosnet.de']);
$redirectUrl = $domainRedirector->getRedirect($request); // https://www.imos.net/de/test.html?x=y

$request = Request::create('/de/test.html?x=y', 'GET', [], [], [], ['HTTP_HOST' => 'www.imos.net', 'HTTPS' => 'ON']);
$redirectUrl = $domainRedirector->getRedirect($request); // false (everything is fine, we dont need any redirect)

$request = Request::create('/de/test.html?x=y', 'GET', [], [], [], ['HTTP_HOST' => 'www.foobar.de']);
$redirectUrl = $domainRedirector->getRedirect($request); // http://www.another-domain.de/de/test.html?x=y

// fallback example
$request = Request::create('/de/test.html?x=y', 'GET', [], [], [], ['HTTP_HOST' => 'www.xyz.de']);
$redirectUrl = $domainRedirector->getRedirect($request); // https://www.imos.net/de/test.html?x=y
```

License
-------

[](#license)

This is open-sourced software licensed under the [MIT license](LICENSE)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~144 days

Total

5

Last Release

3232d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b69f1500c5f1709f1800f7cf76806d72a66b0d14c0b409ad98767710f973f60?d=identicon)[mimez](/maintainers/mimez)

---

Top Contributors

[![okj579](https://avatars.githubusercontent.com/u/40447?v=4)](https://github.com/okj579 "okj579 (2 commits)")[![mimez](https://avatars.githubusercontent.com/u/4172384?v=4)](https://github.com/mimez "mimez (1 commits)")[![pkordylewski](https://avatars.githubusercontent.com/u/623913?v=4)](https://github.com/pkordylewski "pkordylewski (1 commits)")

---

Tags

domainredirect

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imos-domainredirector/health.svg)

```
[![Health](https://phpackages.com/badges/imos-domainredirector/health.svg)](https://phpackages.com/packages/imos-domainredirector)
```

###  Alternatives

[io-developer/php-whois

PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 5.4+ and 7+ compatible

4922.4M8](/packages/io-developer-php-whois)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)[setono/sylius-redirect-plugin

Sylius plugin for managing redirects

26352.1k](/packages/setono-sylius-redirect-plugin)[terminal42/contao-url-rewrite

URL Rewrite bundle for Contao Open Source CMS

1595.3k3](/packages/terminal42-contao-url-rewrite)[twohill/silverstripe-homepagefordomain

Allows to designate a page anywhere in the tree as the homepage for a specific domain, overruling the usual homepage (which is identified by the 'home' URLSegment).

131.3k](/packages/twohill-silverstripe-homepagefordomain)

PHPackages © 2026

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