This waigo plugin provides:
urlSlashSeo
This middleware enhances your SEO by auto-redirecting the client to the correct version of a URL with or without an ending slash when the incorrect version is accessed.
If using this middleware then ensure you write your routes according to your chosen rule, i.e. with or without ending slashes.
Note that this middleware only intercepts GET
and HEAD
requests.
$ npm install waigo-plugin-url-slash-seo
In your configuration file enable it as common middleware:
config.middleware.order = [
'errorHandler',
'staticResources',
'urlSlashSeo', // check now, before any more work is done
'sessions',
'outputFormats'
];
config.middleware.options.urlSlashSeo = {
/* If false then correct URLs don't have a trailing slash. If true they do. */
withSlash: false,
/* If true then redirect with status code 301, else use 302 */
permRedirect: true
};
MIT - see LICENSE.md