PHPackages                             linkeddatacenter/url-rewriter - 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. linkeddatacenter/url-rewriter

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

linkeddatacenter/url-rewriter
=============================

Middleware to change request uri.

1.0.0(6y ago)052MITPHPPHP ^7.0

Since Oct 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/linkeddatacenter/url-rewriter)[ Packagist](https://packagist.org/packages/linkeddatacenter/url-rewriter)[ Docs](https://github.com/linkeddatacenter/url-rewriter)[ RSS](/packages/linkeddatacenter-url-rewriter/feed)WikiDiscussions master Synced 1mo ago

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

linkeddatacenter/url-rewriter
=============================

[](#linkeddatacenterurl-rewriter)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ce77723789ab89b262466a8ececaa34175d1d4231885d2db5aa8201d3676e8b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c696e6b65646461746163656e7465722f75726c2d72657772697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/linkeddatacenter/url-rewriter)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/af629f805fc09fcd608ecace46a18d2ca631ab12f70a575aae1f813c8a4fdcf8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c696e6b65646461746163656e7465722f75726c2d72657772697465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/linkeddatacenter/url-rewriter/build-status/master)[![Quality Score](https://camo.githubusercontent.com/d7b769137cb9403ffe80061ff4058bef4ef84a75016f15853c6564968557a09e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c696e6b65646461746163656e7465722f75726c2d72657772697465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/linkeddatacenter/url-rewriter)

Simple Middleware to rewrite the path, the query and the fragment of the an http request uri. It requires an array of rules that are evaluated in sequence. A rule is a two position array: array\[0\] is the regexp pattern to search (internally translated in #^$pattern$# and array\[1\] is the replacement according the php function *preg\_replace*.

Inspired from [middlewares/base-path](https://github.com/middlewares/base-path)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.0
- A [PSR-7](https://packagist.org/providers/psr/http-message-implementation) http message implementation ([Diactoros](https://github.com/zendframework/zend-diactoros), [Guzzle](https://github.com/guzzle/psr7), [Slim](https://github.com/slimphp/Slim), etc...)
- A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)

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

[](#installation)

This package is installable and autoloadable via Composer as [linkeddatacenter/url-rewriter](https://packagist.org/packages/linkeddatacenter/url-rewriter).

```
composer require linkeddatacenter/url-rewriter
```

Example
-------

[](#example)

```
$dispatcher = new Dispatcher([
	new Middlewares\BasePath([
	[
            '/(\w+)' => '/$1/pluto',
            '/(\w+)/(\w+)/(\w+).(csv|json|xml)(.*)' =>'/$1/docstore?db=$2&table=$3&format=$4$5',
	])
]);

$response = $dispatcher->dispatch(new ServerRequest());
```

Options
-------

[](#options)

#### `__construct(array $rules)`

[](#__constructarray-rules)

rules := array \[ , ,.... \] rule := array \[ , \]

Test with docker
----------------

[](#test-with-docker)

```
docker run --rm -ti -v $PWD/.:/app composer composer install
docker run --rm -ti -v $PWD/.:/app composer vendor/bin/phpunit
```

---

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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 ~351 days

Total

2

Last Release

2420d ago

Major Versions

0.1.0 → 1.0.02019-09-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/cdabb6f1a7cc46c4a299c684f66c7e3ae2fda117fe4db45758c01fe24d66221b?d=identicon)[botk](/maintainers/botk)

---

Top Contributors

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

---

Tags

httppsr-7middlewareserverpsr-15

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/linkeddatacenter-url-rewriter/health.svg)

```
[![Health](https://phpackages.com/badges/linkeddatacenter-url-rewriter/health.svg)](https://phpackages.com/packages/linkeddatacenter-url-rewriter)
```

###  Alternatives

[middlewares/request-handler

Middleware to execute request handlers

451.6M26](/packages/middlewares-request-handler)[middlewares/fast-route

Middleware to use FastRoute

96191.1k15](/packages/middlewares-fast-route)[middlewares/negotiation

Middleware to implement content negotiation

47442.1k11](/packages/middlewares-negotiation)[middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

32466.8k17](/packages/middlewares-payload)[middlewares/http-authentication

Middleware to implement Basic and Digest Http authentication

35302.0k2](/packages/middlewares-http-authentication)[middlewares/client-ip

Middleware to detect the client ip and save it as a request attribute

16629.7k9](/packages/middlewares-client-ip)

PHPackages © 2026

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