-
Notifications
You must be signed in to change notification settings - Fork 14
Redirect Manager
Category | Notes |
---|---|
Module Location | Feature.Redirection |
Recommended | Yes |
Default | On |
Dependencies | None |
Pipelines Targeted | HttpBeginRequest |
Events Targeted | None |
Site Settings | /sitecore/templates/SF/Feature/Redirection/Interface Templates/_SiteRedirectionSettings |
Page Settings | None |
Patch Config | Feature.Redirection\Redirection |
This feature supports two common use cases. Implementing 301 Redirect Rules and making it easy to force https and www to be in the path of the url. For the later, we make it very easy to configure through Site Configuration
To make it easy to keep this configured and bypass it for local development, we have implemented two custom Sitecore Settings that can be used to disable this redirection in your local environment. Simply Set "SF.IgnoreForceHttps" and "SF.IgnoreForceWWW" to true and these rules will not apply.
When it comes to managing redirect rules you have a couple of options with Sitecore. You can leverage the IIS Url Rewrite module which allows you to manage rules in a clunky UI or xml configuration file. Note this file is unforgiving if you manually edit it incorrectly. (Dupes can cause 500 level errors with little hints as to the issue logged anywhere)
For Sitecore, there are a number of modules that allow you to manage rule in Sitecore instead of in configuration files. One of the more popular one is the 301 redirect module, found in the sitecore marketplace: https://marketplace.sitecore.net/Modules/301_Redirect_module.aspx?sc_lang=en
Both approaches, use a global set of rules that apply to every request. To better fit ASF, we have implemented it such that each site can maintain a list of redirection rules. The foundation branch templates have been updated to include an additional "Redirection rules" folder under the Site Configuration Item.
Currently it supports two rule types: Redirect Url which Supports Exact Match
Note the target item is a drop link field so you can specify exactly what item to redirect to. It supports pages and Media Library Items and will preserve any query string parameters attached to the requested url.
The second type is called Redirect Pattern which fully supports Regex. It actually supports two types of Target Patterns: Patterns that target Sitecore Items:
Note the target expression will resolve to the path to a sitecore Item. Query string parameters will be appended per the expression once the actual url is resolved
It also supports fully qualified Url expressions:
Note that to avoid performance hits on the sites these rules only kick off if the Item is not found by the normal Item resolver. The pipeline component that manages it is actually configured after the Item Resolver. Since this approach couples rules to each site, only those rules configured for a site will be tested, which is more efficient than grouping/running rules for every request at a global level.
Additional Enhancements.
This feature has been extended to support a disable flag, the ability to select type of redirect and the ability to trigger a goal when the redirect is triggered.
How to redirect other extensions
(taken from https://github.com/thecadams/301RedirectModule#how-to-redirect-other-extensions, but applies equally to this custom module
Add the extension mapping in IIS for your site.
Go to properties for your site, Home Directory, Configuration button, Mappings tab, Add...
Executable: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Note: The above path will be different for you if you use x64 or a different version of .net. Just use the same path that is mapped to the .aspx extension and it will work.
Extension: .php
All Verbs Script engine: checked Verify that file exists: UNCHECKED (very important) Click OK
Tell Sitecore to process php files:
Open Web.config (This is done in custom include config instead) Do a search for: Sitecore.Pipelines.PreProcessRequest.FilterUrlExtensions Underneath that line, there is a parameter for "Allowed extensions". Add php to the list. DONE! Now you can add rules to this module that redirect .php files.
You can do this exact same process for other extension types like .html, .jpg/.gif/.png, .pdf, etc as well if you need to redirect those.
Introduction
- Getting Started
- Resources
- Supported Versions and Branches
- Sitecore Foundation for SxA
- Layer and Sitecore Dependencies
- Acknowledgements
Feature Guide
- Leveraging the Framework
- Site Configuration Management
- Information Architecture
- Dynamic Placeholders
- Handlebar Renderings
- Scripts and Styles
- Meta Tags
- Social Tags
- Redirect Manager
- Site Map
- IP White Listing
- PDF Generation
- Favicon
- Robots
- Parameterized Renderer
- Site and Feature Cache Cleaning
- Site Error Handling Overrides
- Shell Extensions
- Multilingual Features