Git Product home page Git Product logo

silverstripe-redirectedurls's Introduction

Redirected URLs

Build Status

Author: Sam Minnée

Author: Stig Lindqvist

Author: Russ Michell

This module provides a system for users to configure arbitrary redirections in the CMS. These can be used for legacy redirections, friendly URLs, and anything else that involves redirecting one URL to another.

The URLs may include query-strings, and can be imported from a CSV using the "Redirects" model admin included.

The redirection is implemented as a plug-in to the 404 handler, which means that you can't create a redirection for a page that already exists on the site.

Installation

Either:

  1. Download or git clone the 'redirectedurls' directory to your webroot, or;
  2. Using composer run the following in the command line:

composer require silverstripe/redirectedurls dev-master

  1. Run dev/build (http://www.mysite.com/dev/build?flush=all)

Usage

  1. Click 'Redirects' in the main menu of the CMS.
  2. Click 'Add Redirected URL' to create a mapping of an old URL to a new URL on your SilverStripe website.
  3. Enter a 'From Base' which is the URL from your old website (not including the domain name). For example, "/about-us.html".
  4. Alternatively, depending on your old websites URL structure you can redirect based on a query string using the combination of 'From Base' and 'From Querystring' fields. For exmaple, "index.html" as the base and "page=about-us" as the query string.
  5. As a further alternative, you can include a trailing '/' for a wildcard match to any file with the same stem. For example, "/about/".
  6. Complete the 'To' field which is the URL you wish to redirect traffic to if any traffic from. For example, "/about-us".
  7. Alternatively you can terminate the 'To' field with '/' to redirect to the specific file requested by the user. For example, "/new-about/". Note that if this specific file is not in the target directory tree, the 404 error will be handled by the target site.
  8. Create a new Redirection for each URL mapping you need to redirect.

For example, to redirect "/about-us/index.html?item=1" to "/about-us/item/1", set:

From Base:  /about-us/index.html
From Querystring:  item=1
To:  /about-us/item/1

Importing

  1. Create a CSV file with the columns headings 'FromBase', 'FromQuerystring' and 'To' and enter your URL mappings.
  2. Click 'Redirects' in the main menu of the CMS.
  3. In the 'Import' section click 'Choose file', select your CSV file and then click 'Import from CSV'.
  4. Optionally select the 'Replace data' option if you want to replace the RedirectedURL database table contents with the imported data.

CSV Importer, example file format:

FromBase, FromQuerystring, To
/about-us/index.html, item=1, /about/item/1
/example/no-querystring.html, ,/example/no-querystring/
/example/two-queryparams.html, foo=1&bar=2, /example/foo/1/bar/2
/about/*, ,/about-us

silverstripe-redirectedurls's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.