PHPackages                             settermjd/url-redirector - 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. settermjd/url-redirector

ActiveLibrary

settermjd/url-redirector
========================

This is a simple package that simplifies the process of performing redirects from one absolute URL to another. It's not meant to be, in any way, sophisticated.

0.0.1(8y ago)1101[1 PRs](https://github.com/settermjd/url-redirector/pulls)BSD-3-ClausePHPPHP ^5.6 || ^7.0

Since Jul 27Pushed 8y ago1 watchersCompare

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

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

Absolute URL Redirector
=======================

[](#absolute-url-redirector)

This is a simple package that simplifies the process of performing redirects from one absolute URL to another. It's not meant to be, in any way, sophisticated.

Installing
----------

[](#installing)

To install the module, use Composer by running `composer require settermjd/url-redirector`.

Getting Started
---------------

[](#getting-started)

The constructor takes two arguments:

1. An array. This is a simple key/value list of URLs that require redirecting, and where they should be redirected to
2. The currently requested URL.

The package provides two functions:

- `requiresRedirect()`: This tests if the requested URL requires a redirect
- `getRedirectUrl()`: This retrieves the URL that the current request should be redirected to

If you just want to test, use the first, if you want to redirect, use the second, which uses the first internally.

After initializing the object, pass the return value from `getRedirectUrl()` to PHP's [header](http://php.net/manual/de/function.header.php) function, as in the example below, and the request will be redirected.

```
