Skip to content

A Craft CMS plugin for redirecting legacy URLs to entries.

License

Notifications You must be signed in to change notification settings

miranj/craft-redirector

Repository files navigation

Redirector

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.

  1. Create a new field of type URL. Set the Allowed URL Types to Web Page.

  2. Add this field to all sections where entries have URLs of their own.

  3. 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

About

A Craft CMS plugin for redirecting legacy URLs to entries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published