Documentation Level: 
Advanced
Documentation Status: 
Incomplete

Using URL redirects, you can make your content available to your site visitors using multiple links.

For example, you have built a school website, and you have created a page with the path '/year-one-teachers' and shared this, but have now realised that this page also has all the pictures of the year two teachers as well. What are you to do! You could change the path to something more appropriate such as '/years-one-and-two-teachers', but users may have already bookmarked the old path and did not realise you changed it would now get a "Page not found" error if they tried to access. This is never a good thing for users.

You could also create an entirely new page, with a new path, '/year-two-teachers', but that would mean two pages to maintain, which is also not ideal.

Instead, you could simply create a new redirect to make the path '/year-two-teachers' point to the same page as '/year-one-teachers'.

Note: To create and use URL redirects for your content, you must enable the Redirect module.

Redirect settings

The settings page for Redirect module can be found at Configuration > Search and metadata > URL redirects > settings. The following options are available:

  • Automatically create redirects when URL aliases are changed - this is described in the automatic path redirects section below
  • Retain query string through redirect - for example, given a redirect from source-path to node?a=apples, if a user visits source-path?a=alligators&b=bananas they would be redirected to node?a=apples&b=bananas. The query strings in the redirection will always take precedence over the current query string.
  • Redirect types - this determines which redirect types are available on the Add redirects page. More information about redirect types
    • Show only common redirect types (301 and 302)
    • Show all redirect types (300, 301, 302, 303, 304, 305, and 307)
  • Delete redirects that have not been accessed for - choose whether redirects will expire if not accessed for a given period. Only redirects managed by the redirect module itself will be deleted. Redirects managed by other modules will be left alone.

Automatic path redirects

When certain types of content (such as Post content types) are created, backdrop creates an 'alias', an easy-to-remember URL for this content, usually based on the title of the content. For example, if you created a post with the title "About Dragoons" (error intended), an alias "/about-dragoons" would be created and your post would be available on this new path as well as the core path "node/NID". See the document on Automatic paths for more information.

However, if you realized three days later that you misspelled dragons, and renamed the page title, a new alias would be created then as well: "/about-dragons" (one "O" this time). 

If this were a popular post, users who had bookmarked the URL would get a "Page not found" error if they visited the old "/about-dragoons" path. To prevent this, Backdrop automatically creates a new redirect any time a URL alias is changed, so "/about-dragoons" would now point to the "/about-dragons" page. Users who attempted to visit the mistaken "/about-dragoons" would be silently redirected to the correct page.

Turning off automatic path redirects

If you don't want to use the automatic redirect feature, you can turn it off by completing the following steps:
Go to Configuration > Search and metadata > URL redirects > settings.
Go to the Settings tab.
Clear the Create redirects when published URL aliases are changed check box.
Now, when you edit your title on published content, the URL is not automatically redirected.

Managing existing redirects

Backdrop lists all existing redirects at Configuration > Search and metadata > URL redirects. This table displays the following information about each redirect:

  • From - the original URL accessed by the user
  • To -  the URL to which the user will be redirected
  • Type -  the type of redirect code. See More information about redirect codes. https://wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection
  • Count - how many times the URL has been accessed
  • Last Accessed - the time of last access
  • Operations - Edit and delete operations for the redirect.

A link to add a redirect is also available on this page.

Creating a redirect

Go to Configuration > Search and metadata > URL redirects and click "Add redirect". This launches the Add redirect form.
Enter a From and To path and choose the redirect type.
Save the configuration.

The new redirect will now be listed.

Listing of 404 pages

Backdrop lists all URL access attempts which resulted in a 404 error (Page not found). This may be useful in a situation where your potential website users had been given an incorrect URL for a page on your site, as may happen if someone referenced your page from another site but typed it wrongly. 

You have the option to redirect all 404 pages to the correct URL.

To redirect 404 pages:
Go to Configuration > Search and metadata > URL redirects > Fix 404 pages
Examine the list to see if you need to create any redirects.
To create a redirect click the Add redirect link
Enter the path, alias, or external URL to redirect the link to.
Save the configuration.

You should do this periodically so that your visitors encounter fewer 404 errors.

Redirect list on entity edit pages

The node edit page provides a tab which lists all redirects to the node being edited. A link is also provided to add a redirect.

[image]

Taxonomy term edit pages also provide this list in a fieldset.

[image]