owenmelbz / domain-enforcement
Laravel 5+ middleware to enforce a single domain on your application. e.g non-www. to www.
Installs: 4 839
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 2
Forks: 5
Open Issues: 0
README
An automatic piece of middleware for Laravel 5+, which will force users to access your application via what is defined in the APP_URL - especially useful for SEO forcing non-www users to www etc, unless specified in the ignore list
Usage
-
Install via composer
composer require owenmelbz/domain-enforcement
-
Register the service provider - typically done inside the
app.php
providers array e.gOwenMelbz\DomainEnforcement\DomainEnforcementServiceProvider::class
-
Add
ENFORCE_DOMAIN=true
to your application environment config e.g.env
-
Enjoy your stress free architecture agnostic redirects
Configuration
If you publish the config via php artisan vendor:publish --provider="OwenMelbz\DomainEnforcement\DomainEnforcementServiceProvider"
you can exclude urls from getting enforced.
Why?
Too often we've wasted time configuring redirections, with proxy systems like CloudFlare, with apache development machines and nginx production, this removes all the headache and can simply be turned off and on at a whim.