PHPackages                             yaroslawww/laravel-force-https - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yaroslawww/laravel-force-https

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yaroslawww/laravel-force-https
==============================

Easy redirect to https for Laravel.

3.0.0(4y ago)139.7k3[1 issues](https://github.com/yaroslawww/laravel-force-https/issues)MITPHPPHP ^8.0CI failing

Since Mar 31Pushed 4y agoCompare

[ Source](https://github.com/yaroslawww/laravel-force-https)[ Packagist](https://packagist.org/packages/yaroslawww/laravel-force-https)[ Docs](https://github.com/yaroslawww/laravel-force-https)[ RSS](/packages/yaroslawww-laravel-force-https/feed)WikiDiscussions master Synced today

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

Laravel Force Https
===================

[](#laravel-force-https)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bed5bc5ea0fc638bacfbe34242dbf68047aea9746c27f3c9dea783245a32bef0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7961726f736c617777772f6c61726176656c2d666f7263652d68747470732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yaroslawww/laravel-force-https)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](README.md)[![Total Downloads](https://camo.githubusercontent.com/6c77483aa052e7d8c1cd491a4ac77e3b6b12cbbf70d2bfed926acadf720f7986/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7961726f736c617777772f6c61726176656c2d666f7263652d68747470732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yaroslawww/laravel-force-https)[![Build Status](https://camo.githubusercontent.com/794e0eba5247985ec29da68dff3a2116baba739f44df3a35d461047d102edb8c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7961726f736c617777772f6c61726176656c2d666f7263652d68747470732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yaroslawww/laravel-force-https/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/49815eda74fb11d51574407fdd757e165584b378f4cabe824993fb5a1242d0c1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7961726f736c617777772f6c61726176656c2d666f7263652d68747470732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yaroslawww/laravel-force-https/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/98ebc4ae3b15e6150d1de6d87dfb360d1d5f16d4fa0d4ba3ee7360f3ac51649f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7961726f736c617777772f6c61726176656c2d666f7263652d68747470732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yaroslawww/laravel-force-https/?branch=master)

An easy redirect to https for Laravel.

Redirects using server config
-----------------------------

[](#redirects-using-server-config)

The fastest and easiest way to do a redirect is to configure the server to redirect requests itself (an example is shown below). But in some situations you may not have access to the configuration, or you need to do additional checks using PHP. Then this package comes in handy.

### Redirect using apache2

[](#redirect-using-apache2)

Add to **`.htaccess`**

```
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
```

### Redirect using nginx

[](#redirect-using-nginx)

You need to migrate configurations from port 80 to 443 and then add redirect from port 80 to port 443

```
server {
    listen 443 ssl http2;
    server_name my-domain.example www.my-domain.example;

    # ... configuration
}
server {
    listen 80;
    server_name my-domain.example www.my-domain.example;
    return 301 https://my-domain.example$request_uri;
}

```

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Composer](#composer)
- [Usage](#usage)
    - [Middleware](#middleware)
- [Config](#config)
    - [Config files](#config-files)
    - [Service providers](#service-providers)
- [Changelog](#changelog)
- [License](#license)

Compatibility
-------------

[](#compatibility)

For use php &lt; 8.0 please use version "^2.0"

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

[](#installation)

```
composer require yaroslawww/laravel-force-https
```

Usage
-----

[](#usage)

### Middleware

[](#middleware)

Moreover, this package includes a middleware object to redirect all "non-ssl" routes to the corresponding "ssl".

So, if a user navigates to  and the system has this middleware active it would redirect (301) him automatically to . This is mainly used to avoid duplicate content and improve SEO performance.

To do so, you have to register the middleware in the `app/Http/Kernel.php` file like this:

```
    //app/Http/Kernel.php

    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        /**** OTHER MIDDLEWARE ****/
        'https' => \ForceHttps\Middleware\RedirectToHttps::class,
        // REDIRECTION MIDDLEWARE
    ];
```

```
	// /routes/web.php

	Route::middleware('https')
        ->group(function() {
            /** ADD ALL SECURE ROUTES INSIDE THIS GROUP **/
            Route::get('/', function()
            {
                //
            });

            Route::get('test',function()
            {
                //
            });
        });

	/** OTHER PAGES THAT SHOULD NOT BE SECURE **/
```

Config
------

[](#config)

### Config Files

[](#config-files)

In order to edit the default configuration for this package you may execute:

```
php artisan vendor:publish --provider="ForceHttps\ServiceProvider"
```

After that, `config/force-https.php` will be created. Inside this file you will find all the fields that can be edited in this package.

Since you will typically need to overwrite the assets every time the package is updated, you may use the --force flag:

```
php artisan vendor:publish --provider="ForceHttps\ServiceProvider" --force
```

Changelog
---------

[](#changelog)

View changelog here -&gt; [changelog](CHANGELOG.md)

License
-------

[](#license)

Credits
-------

[](#credits)

- [![Lemeor](https://camo.githubusercontent.com/4b949875daafe2f7bf7d35174af5fe2b42f584ac7fac45aa0017b63b3ac7ff0b/68747470733a2f2f7961726f736c617777772e6769746875622e696f2f696d616765732f73706f6e736f72732f7061636b616765732f6c6f676f2d6c656d656f722e706e67)](https://lemeor.com/)
- [![Think Studio](https://camo.githubusercontent.com/8e541bece07d503c85a126b5294865faa00e27371048772f566a0cce8c01fd3a/68747470733a2f2f7961726f736c617777772e6769746875622e696f2f696d616765732f73706f6e736f72732f7061636b616765732f6c6f676f2d7468696e6b2d73747564696f2e706e67)](https://think.studio/)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity74

Established project with proven stability

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

Recently: every ~366 days

Total

9

Last Release

1737d ago

Major Versions

1.1.1 → 2.0.02020-06-08

2.0.1 → 3.0.02021-09-27

PHP version history (3 changes)1.0.0PHP &gt;=5.6.0

2.0.0PHP &gt;=7.4

3.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23663794?v=4)[yaroslawww](/maintainers/yaroslawww)[@yaroslawww](https://github.com/yaroslawww)

---

Top Contributors

[![yaroslawww](https://avatars.githubusercontent.com/u/23663794?v=4)](https://github.com/yaroslawww "yaroslawww (13 commits)")

---

Tags

httpslaravelsslredirect

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yaroslawww-laravel-force-https/health.svg)

```
[![Health](https://phpackages.com/badges/yaroslawww-laravel-force-https/health.svg)](https://phpackages.com/packages/yaroslawww-laravel-force-https)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k9.6k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90128.1k](/packages/emargareten-inertia-modal)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3614.9k](/packages/linkxtr-laravel-qrcode)[owenmelbz/https-enforcement

Laravel 5.x middleware to enforce https redirection for your app.

252.6k](/packages/owenmelbz-https-enforcement)

PHPackages © 2026

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