PHPackages                             markohs/forcehttps - 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. markohs/forcehttps

ActiveLibrary

markohs/forcehttps
==================

Simple Laravel Middleware to force HTTPS connections

v1.1.0(4y ago)143MITPHPCI failing

Since Jan 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Markohs/ForceHTTPS)[ Packagist](https://packagist.org/packages/markohs/forcehttps)[ Docs](https://github.com/markohs/forcehttps)[ RSS](/packages/markohs-forcehttps/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (13)Used By (0)

ForceHTTPS
==========

[](#forcehttps)

[![Build Status](https://camo.githubusercontent.com/c86d596064b292f371f106c02bc8d2ecf6f8d1fc218fbdf721772ffc214e50f0/68747470733a2f2f7472617669732d63692e6f72672f4d61726b6f68732f466f72636548545450532e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Markohs/ForceHTTPS)[![Latest Version on Packagist](https://camo.githubusercontent.com/bf8060fdb8ee871ff3cd29a143c38c0178207b6d7a484fbcf561aa507fa19a35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61726b6f68732f666f72636568747470732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/markohs/forcehttps)[![Total Downloads](https://camo.githubusercontent.com/f7d136066197ccdfc851a71e27984836ccdbb87b750407188d6a4259dcb889f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61726b6f68732f666f72636568747470732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/markohs/forcehttps)[![StyleCI](https://camo.githubusercontent.com/1bf37502c30a4bcb873ca059e04456e6f31fdee4bdf29a4d88a35d36946510ac/68747470733a2f2f7374796c6563692e696f2f7265706f732f3233373033383730392f736869656c64)](https://styleci.io/repos/237038709)[![](https://camo.githubusercontent.com/25b3e6d0d42c98de74a98cbb4d149a1c09020cf6d1361993b72d7d5b8ffed363/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://makeapullrequest.com)[![](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

Simple Laravel Middleware to force HTTPS usage on your clients, with a simple whitelist system. Take a look at [contributing.md](contributing.md) to see a to do list.

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

[](#installation)

Via Composer

```
$ composer require markohs/forcehttps
```

Publish the default config file:

```
$  php artisan vendor:publish --tag=forcehttps.config

```

You can now edit default settings in config/forcehttps.php

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

[](#requirements)

This package is just tested with Laravel 6.0 and 8.0

Usage
-----

[](#usage)

You can use any of the following methods:

You can either force HTTPS in a single route in for example `routes/web.php`:

```
Route::get('/','StaticPageController@getRoot')->middleware('forcehttps');
```

You can also use the automatic MiddlewareGroup register mechanism in `config/forcehttps.php`:

```
	'autoregister' => ['web']
```

Or you can add the Middleware manually as usual in `app/Http/Kernel.php` in the MiddlewareGroups you require:

```
...
'web' => [
    \App\Http\Middleware\EncryptCookies::class,
...
    \Markohs\ForceSSL\Middleware\ForceHTTPS::class,
...

    \Illuminate\Routing\Middleware\SubstituteBindings::class,
],
...
```

### Set active environments

[](#set-active-environments)

This package will only be active in the environments you specify, by default `stage`, `prod` and `production`, update `config/forcehttps.php` if necessary:

```
    'enabled_environments' => ['stage', 'prod', 'production'],
```

### URL whitelist mechanism

[](#url-whitelist-mechanism)

This package also has a path exclusion mechanism I found useful in my projects. Even if a request is affected by this Middleware, a list of paths is checked, in a "whitelist" spirit, those URLS won't emit a 301 HTTP redirect. I use for comunitaction with other traditional systems that use old POST fashion, and don't support HTTPS.

You can set this url whitelist in `config/forcehttps.php`:

```
    'whitelist' => [
        'example/url',
        'example2'
    ],
```

Important notes
---------------

[](#important-notes)

If you are using Cloudflare or some kind of proxy to serve your website, you need to make sure you configure TrustedProxy correctly *or this Middleware will cause redirect loops*.

Make sure you keep the config file `/config/trustedproxy.php`, or on `app\Http\Middleware\TrustProxies.php` , variable `$proxies`, up to date. Or

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, or want to help improve this package, please email  or use the issue tracker or send a PR.

Credits
-------

[](#credits)

- [Markohs](https://github.com/markohs)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~44 days

Recently: every ~119 days

Total

12

Last Release

1812d ago

Major Versions

v0.1.2 → v1.0.02020-02-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1194268?v=4)[Marcos Lopez](/maintainers/Markohs)[@Markohs](https://github.com/Markohs)

---

Top Contributors

[![Markohs](https://avatars.githubusercontent.com/u/1194268?v=4)](https://github.com/Markohs "Markohs (23 commits)")[![kbfrench](https://avatars.githubusercontent.com/u/194268?v=4)](https://github.com/kbfrench "kbfrench (1 commits)")

---

Tags

httpslaravelmiddlewarehttpsmiddlewarelaravelForceHTTPS

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/markohs-forcehttps/health.svg)

```
[![Health](https://phpackages.com/badges/markohs-forcehttps/health.svg)](https://phpackages.com/packages/markohs-forcehttps)
```

###  Alternatives

[barryvdh/laravel-stack-middleware

Stack Middleware for Laravel

43415.4k5](/packages/barryvdh-laravel-stack-middleware)[json-mapper/laravel-package

The JsonMapper package for Laravel

25170.4k3](/packages/json-mapper-laravel-package)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)

PHPackages © 2026

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