PHPackages                             kaufmanndigital/domainredirection - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kaufmanndigital/domainredirection

ActiveNeos-package[Utility &amp; Helpers](/categories/utility)

kaufmanndigital/domainredirection
=================================

Package to redirect A whole Domain and based on Regex-rules.

1.0.1(7mo ago)0230↓33.3%MITPHP

Since Oct 1Pushed 7mo agoCompare

[ Source](https://github.com/KaufmannDigital/KaufmannDigital.DomainRedirection)[ Packagist](https://packagist.org/packages/kaufmanndigital/domainredirection)[ RSS](/packages/kaufmanndigital-domainredirection/feed)WikiDiscussions main Synced 1mo ago

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

KaufmannDigital.DomainRedirection
=================================

[](#kaufmanndigitaldomainredirection)

A flexible Neos CMS package for configuring domain and path-based HTTP redirects using plain strings or regex patterns.

Features
--------

[](#features)

- **Domain-based redirects**: Redirect entire domains to new locations
- **Regex support**: Use regex patterns for both domain matching and path transformations
- **Path transformation rules**: Define multiple rules per domain with regex patterns
- **Custom status codes**: Configure individual status codes (301, 302, 307, etc.) per redirect
- **Capture group support**: Use regex capture groups (`$1`, `$2`, etc.) in replacements
- **Flexible configuration**: Works with plain domain strings or complex regex patterns
- **HTTP Middleware**: Runs after Neos redirect middleware for optimal performance

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

[](#installation)

Install via Composer:

```
composer require kaufmanndigital/domainredirection
```

Configuration
-------------

[](#configuration)

Add your redirect configuration to your `Settings.yaml`:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'old-domain.com'
        target: 'https://new-domain.com'
        statusCode: 301
```

Usage Examples
--------------

[](#usage-examples)

### 1. Simple Domain Redirect

[](#1-simple-domain-redirect)

Redirect an entire domain to a new location:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'old-domain.com'
        target: 'https://new-domain.com'
        statusCode: 301
```

**Result:**

- `old-domain.com` → `https://new-domain.com`
- `old-domain.com/any/path` → `https://new-domain.com`

### 2. Domain Redirect with Path Preservation

[](#2-domain-redirect-with-path-preservation)

Use regex to preserve and transform the path:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'old-domain.com/(.*)$'
        target: 'https://new-domain.com/$1'
        statusCode: 301
```

**Result:**

- `old-domain.com/about` → `https://new-domain.com/about`
- `old-domain.com/contact/form` → `https://new-domain.com/contact/form`

### 3. Subdomain to Path Redirect

[](#3-subdomain-to-path-redirect)

Redirect a subdomain to a specific path on the main domain:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'blog.example.com'
        target: 'https://example.com/blog'
        statusCode: 307
```

**Result:**

- `blog.example.com` → `https://example.com/blog`
- `blog.example.com/article` → `https://example.com/blog`

### 4. Subdomain with Path Transformation

[](#4-subdomain-with-path-transformation)

Redirect a subdomain and append the path to a specific location:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'karriere.example.com/(.*)$'
        target: 'https://example.com/careers#$1'
        statusCode: 307
```

**Result:**

- `karriere.example.com/jobs` → `https://example.com/careers#jobs`
- `karriere.example.com/apply/form` → `https://example.com/careers#apply/form`

### 5. Path-Specific Rules

[](#5-path-specific-rules)

Define multiple rules for different path patterns on the same domain:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'example.com'
        target: 'https://new-example.com'
        statusCode: 301
        rules:
          - pattern: '^/old-section/(.*)$'
            replacement: '/new-section/$1'
            statusCode: 301
          - pattern: '^/legacy/(.*)$'
            replacement: '/modern/$1'
            statusCode: 302
```

**Result:**

- `example.com/old-section/page` → `https://new-example.com/new-section/page`
- `example.com/legacy/content` → `https://new-example.com/modern/content` (302)
- `example.com/other` → `https://new-example.com` (fallback)

### 6. Multiple Domains with Different Rules

[](#6-multiple-domains-with-different-rules)

Configure multiple domain redirects in the same configuration:

```
KaufmannDigital:
  DomainRedirection:
    redirects:
      - domainPattern: 'old-site.com'
        target: 'https://new-site.com'
        statusCode: 301

      - domainPattern: 'beta.example.com'
        target: 'https://example.com/beta'
        statusCode: 307
        rules:
          - pattern: '^/test/(.*)$'
            replacement: '/testing/$1'
            statusCode: 302
```

Configuration Options
---------------------

[](#configuration-options)

### Main Configuration

[](#main-configuration)

- **`domainPattern`** (required): Domain to match. Can be:

    - Plain string: `'example.com'`
    - Regex pattern: `'example.com/(.*)$'`
- **`target`** (required): Target URL to redirect to
- **`statusCode`** (optional, default: 301): HTTP status code for the redirect

    - `301` - Permanent redirect
    - `302` - Temporary redirect
    - `307` - Temporary redirect (preserves HTTP method)
    - `308` - Permanent redirect (preserves HTTP method)
- **`pattern`** (optional): Regex pattern for path transformation (alternative to using regex in `domainPattern`)
- **`rules`** (optional): Array of path-specific rules

### Rules Configuration

[](#rules-configuration)

- **`pattern`** (required): Regex pattern to match against the path
- **`replacement`** (required): Replacement string (can include capture groups like `$1`, `$2`)
- **`statusCode`** (optional): Override status code for this specific rule

How It Works
------------

[](#how-it-works)

1. The middleware checks each configured redirect in order
2. If `domainPattern` matches (either as plain string or regex):
    - First, it checks if any `rules` match the current path
    - If a rule matches, it applies the rule's transformation
    - If no rule matches, it uses the default `target`
3. The middleware runs **after** the Neos redirect middleware
4. If no redirect matches, the request continues to the next middleware

License
-------

[](#license)

This package is licensed under the MIT License.

Author
------

[](#author)

KaufmannDigital GmbH -

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance68

Regular maintenance activity

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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

Every ~0 days

Total

2

Last Release

219d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/kaufmanndigital-domainredirection/health.svg)

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

###  Alternatives

[sitegeist/monocle

An living-styleguide for Neos that is based on the actual fusion-code

45315.9k10](/packages/sitegeist-monocle)[sitegeist/kaleidoscope

Responsive-images for Neos

29352.4k10](/packages/sitegeist-kaleidoscope)[flowpack/listable

Tiny extension for listing things

35209.0k7](/packages/flowpack-listable)[kaufmanndigital/gdpr-cookieconsent

A ready-to-run package, that integrates an advanced cookie consent banner into your Neos CMS site.

2540.7k](/packages/kaufmanndigital-gdpr-cookieconsent)[neos/seo

SEO configuration and tools for Neos

13990.5k24](/packages/neos-seo)[shel/neos-colorpicker

A plugin for Neos CMS which provides a colorpicker editor

1494.4k6](/packages/shel-neos-colorpicker)

PHPackages © 2026

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