Giter VIP home page Giter VIP logo

nglasl / silverstripe-misdirection Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 17.0 6.02 MB

This module allows both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling.

License: BSD 3-Clause "New" or "Revised" License

PHP 89.78% CSS 2.51% JavaScript 7.71%
silverstripe link-mapping url page-not-found redirect http-404 mapping redirection

silverstripe-misdirection's Introduction

The current release is 3.1.1

This module allows both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling.

Requirement

  • SilverStripe 3.1 โ†’ 4.0

This module does not require the CMS.

This repository is no longer supported, however this module is still supported here.

Getting Started

Overview

Link Mappings

These allow both simple and regular expression link redirections, and can be used for legacy page redirection, vanity URLs (more below), or redirection based on specific URL patterns.

link-mapping

The link mapping with the highest priority (followed by greatest specificity) will be used, and replaces the default automated URL handling out of the box. This default behaviour may be configured to only hook into a page not found:

nglasl\misdirection\MisdirectionRequestFilter:
  enforce_misdirection: false

When there are multiple matches, the link mapping first created will be used. This default behaviour may be configured to prioritise the link mapping most recently created:

nglasl\misdirection\LinkMapping:
  priority: 'DESC'

Vanity URLs and Fallbacks

vanity-URLs-and-fallbacks

Vanity URLs

While it is possible to create these manually (as above), a content author may directly create a link mapping from a page. However, it should be noted that these are instantiated with a low priority of 2, and therefore other link mappings with higher priority will take precedence.

Fallbacks

When a user happens to encounter a page not found, a specified rule may be triggered to prevent displaying this. It is possible for an administrator to configure a global fallback through the site configuration, however a specific page setting will take precedence.

  • Select Settings
  • Select Pages

What's Happening?

The link mappings are processed server side to prevent inefficient and problematic mappings, using a request filter.

When you want to see exactly what is happening behind the scenes for a given URL, the model admin provides a powerful testing interface!

testing

Once a maximum number of requests has been reached, the server will respond with a page not found. The following is the default configuration:

nglasl\misdirection\MisdirectionRequestFilter:
  maximum_requests: 9

testing-maximum-requests

Bypassing Misdirection

It is possible to bypass the request filter completely by appending ?misdirected=1 to the URL. This is fantastic for debugging, however does not apply to the testing interface for obvious reasons.

Default Automated URL Handling

This may be completely replaced, in which case legacy URLs will no longer resolve based on page version history.

nglasl\misdirection\MisdirectionRequestFilter:
  replace_default: true

When a page is moved, the appropriate link mappings are automatically created and maintained. This allows full control over which legacy URLs remain in the system.

Maintainer Contact

Nathan Glasl, [email protected]

silverstripe-misdirection's People

Contributors

nglasl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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