Download the PHP package divineomega/seo-middleware without Composer
On this page you can find all versions of the php package divineomega/seo-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download divineomega/seo-middleware
More information about divineomega/seo-middleware
Files in divineomega/seo-middleware
Package seo-middleware
Short Description SEO Middleware - middleware to redirect to HTTPS when in production, and remove www. from URLs
License LGPL-3.0-only
Homepage https://github.com/DivineOmega/SEO-Middleware
Informations about the package seo-middleware
SEO Middleware
This package contains various middleware classes that can be uses with Laravel 5.1 and above to easily add various SEO benefits to your site / web application.
Features
- Redirecting production HTTP requests to HTTPS
- Removal of
www.
from requests and redirecting - Middleware classes can be applied global or to specific routes
Quick Start
- Run
composer require divineomega/seo-middleware
. - In the
$middleware
array in yourapp/Http/Kernel.php
file:- For HTTP to HTTPS redirects, add
\DivineOmega\SeoMiddleware\Http\Middleware\HttpsOnly::class
. - For removal of
www.
from requests, add\DivineOmega\SeoMiddleware\Http\Middleware\RemoveWww::class
.
- For HTTP to HTTPS redirects, add
- Remember to set the
APP_ENV
variable toprod
(in the project's.env
file) when the application is running in production. Some middleware will only function when this is set to allow for easier local development.
Available Middleware Classes
Any of these middleware classes can be used globally, by adding them to
the $middleware
array in apps/Http/Kernel.php
file. They can also be used
on a per route basis, by adding them to the $routeMiddleware
array in the
same file and then associated them with a route in your apps/Http/routes.php
file.
HttpsOnly Middleware
The HttpsOnly
middleware will redirect any HTTP request to their HTTPS
equivalents. The security of websites is becoming an ever increasing ranking
signal for search engine rankings.
The HTTP to HTTPS redirect will only take place if the application environment
is set to prod
(production), to aid with local development environments in
the setup of HTTPS can be difficult and in many cases unnecessary. Changing
this setting can be set in your project's .env
file, as shown in the example
extracts below.
RemoveWww Middleware
The RemoveWww
middleware will check for www.
within the URL of any requests
made to your web application and then redirect them to a version of the URL
without the www.
removed. This can be beneficial for SEO purposes by the
potential for similar URLs to be indexed with the same content.
This redirect will occur regardless of the application environment (APP_ENV
)
setting.