A Drupal 7 field formatter for Link, Node Reference & User Reference, Term Reference (as of v2.4) and EntityReference (as of v2.4) fields that will perform a HTTP redirect to the given URL, node, user, term or entity object page. A field settings widget is provided to allow selection of the appropriate HTTP status code. Featured on the Lullabot Module Monday blog (September 3rd, 2012).
The recommended usage is to create a custom display setting for the "Full content", pick one of the redirect status codes above, e.g. 301, and hide all other fields to reduce processing & load time.
To configure the recommended settings:
- Go to the "Manage Display" tab on the settings page for the entity of choice (user, content type, etc) settings page; for example, to work with the content type "redirect_user", go to the URL: http://example.com/admin/structure/types/manage/redirect_user/display (where "example.com" is your site's hostname).
- Expand the "Custom display settings" fieldset and ensure the "Full content" checkbox is checked.
- Click the "Save" button.
- Go to the "Full Content" tab.
- Ensure that all of the fields are hidden except for the field you wish to use.
- Click the selector in the Format column of the field in question.
- Select the HTTP status code to use for the redirect - see below, though 301 is usually the best option.
- Click the "Save" button.
- Ensure that other display modes do not use the redirect.
For completeness sake this module provides all of the allowed HTTP status codes that are valid for redirection:
- 300 - "multiple choices".
- 301 - "moved permanently" - The best option for most use cases, indicates that the current path will not be made available again and links should be updated to the new path.
- 302 - "found" - Usually used to indicate a temporary redirect, but also that there may be technical problems causing the redirection.
- 303 - "see other".
- 304 - "not modified".
- 305 - "use proxy".
- 307 - "temporary redirect" - Best to use if the path is purposefully only being redirected temporarily and this current path will be made available for display again at a later time. If the current path will not be made available again it would be better to use status code 301 instead.
The most commonly used are 301 and 307.
Further reading: http://en.wikipedia.org/wiki/URL_redirection
Why a separate module?
This was written as a separate module rather than an expansion of the D7 port of CCK_Redirection purely to keep it small & simple, without adding any extra fields or deal with migration of D6 data. Also, be separating it from the data storage it has allowed it to be extended to support other field types and not just URL fields.
This field formatter should *only* be used when displaying the "full content" of a given entity (user, content type, etc), otherwise unexpected results will happen. Example problems that can arise include:
- Using this formatter for a view mode used on the search index could cause the search index to never complete, or even cron to never complete.
- Using this formatter in an RSS feed would cause all readers of the RSS feed to be instantly redirected to the path provided by this field, rather than seeing the feed itself.
- Using this formatter in a teaser would cause any page that displayed this entity in its content list, e.g. possibly the site's homepage, to redirect.
There are a few known (and reasonable) limitations to this module:
- Only the first item in a field will be used, so allowing more than one value on the field will have no purpose.
- If several items on a given entity have fields that all are set to redirect, the first field that is processed during the page load will be the one that redirects.
v1 vs v2
Version 1 provided seven different formatters and no settings form, thus was limited in functionality. Version 2 wrapped these into a single formatter with a settings form that then added additional features, e.g. optionally giving a 404 error if no value was provided, etc.
Based on the CCK_Redirection module by Robin Monks for Drupal 5 and 6. The idea of just providing formatters rather than a fully separate field type was from user e2thex who suggested the idea during discussion of the Drupal 7 port of CCK_Redirection.
Current development sponsored by Mediacurrent.
- Maintenance status: Actively maintained
- Development status: Under active development
- Reported installs: 3,439 sites currently report using this module. View usage statistics.
- Downloads: 221,910
- Automated tests: Enabled
- Last modified: 22 February 2016
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.