Middleware to add or remove the www subdomain in the host uri and returns a redirect response

v1.1.0 2018-08-04 10:41 UTC

README

Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

Middleware to add or remove the www subdomain in the host uri and returns a redirect response. The following types of hosts wont be changed:

  • The one word hosts, for example: http://localhost.
  • The ip based hosts, for example: http://0.0.0.0.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/www.

composer require middlewares/www

Example

$dispatcher = new Dispatcher([
	new Middlewares\Www(false)
]);

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

Options

__construct(bool $www)

Set true to add the www subdomain and false to remove it.

responseFactory(Psr\Http\Message\ResponseFactoryInterface $responseFactory)

A PSR-17 factory to create 301 responses.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

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