PHPackages                             samsonasik/force-https-module - 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. samsonasik/force-https-module

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

samsonasik/force-https-module
=============================

Force Https Module for Laminas Mvc and Mezzio application

5.1.0(4mo ago)188.9k↓50%1MITPHPPHP ^8.2CI passing

Since Jan 17Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/samsonasik/ForceHttpsModule)[ Packagist](https://packagist.org/packages/samsonasik/force-https-module)[ Docs](https://github.com/samsonasik/ForceHttpsModule)[ GitHub Sponsors](https://github.com/samsonasik)[ RSS](/packages/samsonasik-force-https-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (50)Used By (0)

ForceHttpsModule
================

[](#forcehttpsmodule)

[![Latest Version](https://camo.githubusercontent.com/3bdecdff7aa957ea8b03c8675ba0771cdee87fd154296982811fc28b7aaf7205/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73616d736f6e6173696b2f466f72636548747470734d6f64756c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/samsonasik/ForceHttpsModule/releases)[![ci build](https://github.com/samsonasik/ForceHttpsModule/workflows/ci%20build/badge.svg)](https://github.com/samsonasik/ForceHttpsModule/workflows/ci%20build/badge.svg)[![Code Coverage](https://camo.githubusercontent.com/fb73994b03a10b439be1e15b143e75bcd4526b13a96b7b34aca6a1ffe90efa89/68747470733a2f2f636f6465636f762e696f2f67682f73616d736f6e6173696b2f466f72636548747470734d6f64756c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/samsonasik/ForceHttpsModule)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)[![Downloads](https://camo.githubusercontent.com/f0c8d47e51023bce51951005b97cf3f90b1e7f40ed7925df077b1409f97c1712/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6173696b2f666f7263652d68747470732d6d6f64756c652f646f776e6c6f616473)](https://packagist.org/packages/samsonasik/force-https-module)

Introduction
------------

[](#introduction)

ForceHttpsModule is a configurable module for force https in your [Laminas Mvc](https://docs.laminas.dev/tutorials/) and [Mezzio](https://docs.mezzio.dev/mezzio/) Application.

> This is README for version ^5.0 which only support Laminas Mvc version 3 and Mezzio version 3 with php ^8.2.

> For ^4.1.x, you can read at [version 4.1.x readme](https://github.com/samsonasik/ForceHttpsModule/blob/4.1.x/README.md) which only support Laminas Mvc version 3 and Mezzio version 3 with php ^7.4|~8.0

> For ~4.0.0, you can read at [version 4.0.x readme](https://github.com/samsonasik/ForceHttpsModule/blob/4.0.x/README.md) which only support Laminas Mvc version 3 and Mezzio version 3 with php ^7.3|~8.0

> For version ^3.0, you can read at [version 3 readme](https://github.com/samsonasik/ForceHttpsModule/tree/3.x.x) which only support Laminas Mvc version 3 and Mezzio version 3 with php ^7.1.

> For version ^2.0, you can read at [version 2 readme](https://github.com/samsonasik/ForceHttpsModule/tree/2.x.x) which only support ZF3 and ZF Expressive version 3 with php ^7.1.

> For version 1, you can read at [version 1 readme](https://github.com/samsonasik/ForceHttpsModule/tree/1.x.x) which still support ZF2 and ZF Expressive version 1 and 2 with php ^5.6|^7.0 support.

Features
--------

[](#features)

- Enable/disable force https.
- Force Https to All routes.
- Force Https to All routes except exclusion list.
- Force Https to specific routes only.
- Keep headers, request method, and request body.
- Enable/disable HTTP Strict Transport Security Header and set its value.
- Allow add `www.` prefix during redirection from http or already https.
- Allow remove `www.` prefix during redirection from http or already https.
- Force Https for 404 pages

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

[](#installation)

**1. Require this module uses [composer](https://getcomposer.org/).**

```
composer require samsonasik/force-https-module
```

**2. Copy config**

***a. For [Laminas Mvc](https://docs.laminas.dev/tutorials/) application, copy `force-https-module.local.php.dist` config to your local's autoload and configure it***

sourcedestinationvendor/samsonasik/force-https-module/config/force-https-module.local.php.distconfig/autoload/force-https-module.local.phpOr run copy command:

```
cp vendor/samsonasik/force-https-module/config/force-https-module.local.php.dist config/autoload/force-https-module.local.php
```

***b. For [Mezzio](https://docs.mezzio.dev/mezzio/) application, copy `mezzio-force-https-module.local.php.dist` config to your local's autoload and configure it***

sourcedestinationvendor/samsonasik/force-https-module/config/mezzio-force-https-module.local.php.distconfig/autoload/mezzio-force-https-module.local.phpOr run copy command:

```
cp vendor/samsonasik/force-https-module/config/mezzio-force-https-module.local.php.dist config/autoload/mezzio-force-https-module.local.php
```

When done, you can modify your local config:

```
