miranj / craft-redirector
A Craft CMS plugin for redirecting URLs to entries.
Installs: 263
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- php: ^7.4 || ^8.0
- craftcms/cms: ^3.7.0 || ^4.0.0 || ^5.0
Requires (Dev)
- craftcms/phpstan: dev-main
- craftcms/rector: dev-main
This package is auto-updated.
Last update: 2024-12-20 20:35:20 UTC
README
A Craft CMS plugin for handling legacy paths and URLs by preventing 404s and redirecting to the new entry's URL.
Contents
Usage
In order to handle legacy paths and URLs, we need to create a field to capture them. We can make use of Craft's built-in URL field for this purpose.
-
Create a new field of type URL. Set the Allowed URL Types to Web Page.
-
Add this field to all sections where entries have URLs of their own.
-
Create a config file for this plugin
config/redirector.php
and add the handle of the field created in the first step.<?php return [ 'redirectField' => 'legacyUrl', ];
Installation
You can install this plugin with Composer.
Open your terminal and run the following commands:
# go to the project directory
cd /path/to/project
# tell composer to use the plugin
composer require miranj/craft-redirector:dev-dev
# tell Craft to install the plugin
./craft plugin/install redirector
Requirements
This plugin requires Craft CMS 3, 4, or 5.
Brought to you by Miranj