PHPackages                             terminal42/contao-url-rewrite - 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. terminal42/contao-url-rewrite

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

terminal42/contao-url-rewrite
=============================

URL Rewrite bundle for Contao Open Source CMS

1.8.8(1mo ago)15102.5k—7.2%73MITPHPPHP ^8.1CI passing

Since Sep 18Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/terminal42/contao-url-rewrite)[ Packagist](https://packagist.org/packages/terminal42/contao-url-rewrite)[ GitHub Sponsors](https://github.com/terminal42)[ Fund](https://ko-fi.com/terminal42)[ RSS](/packages/terminal42-contao-url-rewrite/feed)WikiDiscussions main Synced 4d ago

READMEChangelog (10)Dependencies (45)Versions (40)Used By (3)

URL Rewrite bundle for Contao Open Source CMS
=============================================

[](#url-rewrite-bundle-for-contao-open-source-cms)

The extension provides a new way for Contao to set various URL rewrites. The available config providers are:

- Bundle config provider – the entries are taken from `config.yml` file
- Database provider – the entries are taken from backend module

Behind the scenes, the rules are added as routes to the internal application router which allows to use all the features provided by the Symfony Routing component.

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

[](#installation)

Install the bundle via Composer:

```
composer require terminal42/contao-url-rewrite

```

Migration of short URLs
-----------------------

[](#migration-of-short-urls)

Since the extension [fritzmg/contao-short-urls](https://packagist.org/packages/fritzmg/contao-short-urls) has been abandoned, you can migrate short URLs to URL rewrites with the extension [bwein-net/contao-migrate-short-urls](https://packagist.org/packages/bwein-net/contao-migrate-short-urls).

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

[](#configuration)

### Bundle configuration

[](#bundle-configuration)

The bundle configuration is optional. Here you can define the entries and disable the backend management module.

**Note:** if you want to use the `%` character, make sure it is properly escaped by doubling it `%%`.

```
# config/config.yml
terminal42_url_rewrite:
    backend_management: false # Disable backend management of entries (true by default)
    entries: # Optional entries
        -
            request: { path: 'find/{address}' }
            response: { code: 303, uri: 'https://www.google.com/maps?q={address}' }

        -
            request:
                path: 'news/{news}'
                requirements: {news: '\d+'}
            response:
                code: 301
                uri: '{{news_url::{news}|absolute}}'

        -
            request:
                path: 'home.php'
                hosts: ['localhost']
                condition: "context.getMethod() == 'GET' and request.query.has('page')"
            response:
                uri: '{{link_url::{page}|absolute}}'
```

### Running under non Contao managed edition

[](#running-under-non-contao-managed-edition)

If you are running the Contao Managed Edition then the extension should work out of the box. For all the other systems you have to additionally register the routing configuration in the config files:

```
# config/routing.yml
imports:
  - { resource: '@Terminal42UrlRewriteBundle/Resources/config/routing.yml' }
```

Examples
--------

[](#examples)

1. Find address on Google Maps:

```
Path restriction: find/{address}
Response code: 303 See Other
Response URI: https://www.google.com/maps?q={address}
---
Result: domain.tld/find/Switzerland → https://www.google.com/maps?q=Switzerland

```

2. Redirect to a specific news entry:

```
Path restriction: news/{news}
Requirements: [news => \d+]
Response code: 301 Moved Permanently
Response URI: {{news_url::{news}|absolute}}
---
Result: domain.tld/news/123 → domain.tld/news-reader/foobar-123.html
Result: domain.tld/news/foobar → 404 Page Not Found

```

3. Rewrite legacy URLs with query string:

```
Path restriction: home.php
Request condition: context.getMethod() == 'GET' and request.query.has('page')
Response code: 301 Moved Permanently
Response URI: {{link_url::{page}|absolute}}
---
Result: domain.tld/home.php?page=123 → domain.tld/foobar-123.html

```

4. Rewrite URLs including slashes (without query string) to new domain:

```
Hosts restriction: [domain.com]
Path restriction: /{wildcard}
Requirements: [wildcard => .*]
Response code: 301 Moved Permanently
Response redirect URL: https://domain.tld/{wildcard}
---
Result: domain.com/blog/test → https://domain.tld/blog/test

```

Create a custom config provider
-------------------------------

[](#create-a-custom-config-provider)

In addition to the existing providers you can create your own class that provides the rewrite configurations. The new service must implement the [Terminal42\\UrlRewriteBundle\\ConfigProvider\\ConfigProviderInterface](src/ConfigProvider/ConfigProviderInterface.php)interface and be registered with the appropriate tag:

```
services:
    app.my_rewrite_provider:
        class: AppBundle\RewriteProvider\MyRewriteProvider
        public: false
        tags:
            - { name: terminal42_url_rewrite.provider, priority: 128 }
```

Resources
---------

[](#resources)

1. [Symfony Routing](https://symfony.com/doc/current/routing.html)
2. [Symfony Routing Component](https://symfony.com/doc/current/components/routing.html)
3. [How to Restrict Route Matching through Conditions](https://symfony.com/doc/current/routing/conditions.html)
4. [How to Define Route Requirements](https://symfony.com/doc/current/routing/requirements.html)

###  Health Score

64

—

FairBetter than 99% of packages

Maintenance92

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 66.5% 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 ~83 days

Recently: every ~55 days

Total

39

Last Release

39d ago

PHP version history (4 changes)1.0.0PHP &gt;=7.1

1.4.0PHP &gt;=7.2

1.6.0PHP ^7.2 || ^8.0

1.8.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/481937?v=4)[Yanick Witschi](/maintainers/Toflar)[@Toflar](https://github.com/Toflar)

---

Top Contributors

[![qzminski](https://avatars.githubusercontent.com/u/193483?v=4)](https://github.com/qzminski "qzminski (123 commits)")[![Toflar](https://avatars.githubusercontent.com/u/481937?v=4)](https://github.com/Toflar "Toflar (21 commits)")[![aschempp](https://avatars.githubusercontent.com/u/1073273?v=4)](https://github.com/aschempp "aschempp (20 commits)")[![rabauss](https://avatars.githubusercontent.com/u/14016098?v=4)](https://github.com/rabauss "rabauss (9 commits)")[![dmolineus](https://avatars.githubusercontent.com/u/1186266?v=4)](https://github.com/dmolineus "dmolineus (7 commits)")[![richardhj](https://avatars.githubusercontent.com/u/1284725?v=4)](https://github.com/richardhj "richardhj (3 commits)")[![lukasbableck](https://avatars.githubusercontent.com/u/42083846?v=4)](https://github.com/lukasbableck "lukasbableck (1 commits)")[![de-es](https://avatars.githubusercontent.com/u/7645771?v=4)](https://github.com/de-es "de-es (1 commits)")

---

Tags

urlcontaoredirectrewrite

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/terminal42-contao-url-rewrite/health.svg)

```
[![Health](https://phpackages.com/badges/terminal42-contao-url-rewrite/health.svg)](https://phpackages.com/packages/terminal42-contao-url-rewrite)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[contao-community-alliance/dc-general

Universal data container for Contao

1680.8k92](/packages/contao-community-alliance-dc-general)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)

PHPackages © 2026

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