hand-pointing Boost SEO with URL Redirects in Drupal

Make content easy to find on your Drupal hosted website by using the Redirect module.

In a perfect digital world, all web pages are always properly linked, website visitors never hit a "404" page, and Google generously rewards your SEO efforts. However, we sometimes need to do some small fixes to achieve this perfect picture. These small fixes are URL redirects, and every website owner has to deal with them at one point or another. 

Many of our long-term customers have content-heavy Drupal websites, so we at the ImageX Drupal development team know firsthand how important it is for them to be able to do redirects in a convenient way. Here is our advice for managing URL redirects with Drupal:

What are URL redirects

Redirects are used to forward users and search engines from an old URL to a new one. URL #1 is what a user has requested by typing or clicking, and URL #2 is the destination URL where they actually arrive.

With this kind of "teleportation," you greatly improve your website's UX and reduce the bounce rate. You help users find what they are looking for, even if a specific page has been removed, merged with another one, moved to a new domain, and so on. You protect them from landing on a 404 page, which they would otherwise do when opening the link to a page that no longer exists.

Discoverability factors influence your SEO ranking as well. And by using redirects, you let search engines know that the valuable content has been moved to a new address. This helps them better understand the structure of your website and crawl the right pages. If your page has backlinks from other internal or external pages and you need to change its URL, a redirect gives a signal to Google that all the link authority should be transferred to the new page.

You can use redirects if you remove stale content from websites, if you find a typo in an internal link, or if you need to redirect to a new page temporarily because of a promotion.

Getting started with URL redirects

URL redirects for Drupal websites can be made on the server, but this requires technical skills. Fortunately, Drupal has contributed modules for easy redirects, and the most important of them is the Redirect module. This module is widely used — it is currently installed on over 260,000 Drupal websites.

The highly recommended way to install modules on websites using Drupal 8 or higher is via Composer:

composer require drupal/redirect

The module comes packed with three submodules that can be enabled depending on your Drupal website's specific needs:

  • Redirect. This is the main module that provides a user interface for forwarding one URL to another.
  • Redirect 404. This submodule tracks 404 errors and enables you to create redirects for the requested but non-existent URL paths.
  • Redirect Domain. This submodule will be helpful if you need to do redirects from one domain to another. 
The Redirect module with its submodules
The Redirect module with its submodules

The Redirect module

Go to the Configuration > Search and metadata > URL redirects page of your Drupal admin dashboard and you will see the user interface provided by the module. All your redirects will be found on the URL Redirects tab. You will be able to find the necessary ones by filtering.

The main tab in the module's user interface
The main tab in the module's user interface

To create a simple redirect on your Drupal website, click "Add redirect" on the URL Redirects tab and do these three steps:

1. Type the old URL in the "Path" field. This is only the path after the domain (such as redirect/me).

2. Type the new URL in the "To" field. Use a relative internal path (like /path/to/page) or an absolute external path (such as https://example.com/path/to/page).

Creating a simple manual redirect
Creating a simple manual redirect

3. Select the HTTP status code from the dropdown menu, the default one being 301. There are 7 codes to choose from. However, 301 and 302 are the most commonly used ones:

  • 301 means the page is moved to a new address permanently. Use it when you remove or merge a page, want to fix a typo, or make similar redirects.
  • 302 means the page is moved to a new address temporarily. Use it when you need a redirect during a temporary promotional campaign, or when your Drupal website is under maintenance.

Fixing 404 pages

If you have the Redirect 404 submodule enabled, you will also have the "Fix 404 pages" tab available. It lists all the URL paths that have been requested but couldn't be found because they didn't exist on your Drupal website (for example, when a user made a spelling mistake when typing in the address). You can see the statistics for each path, and click "Add redirect" or "Ignore" next to each of them in the Operations dropdown.

The interface for tracking and fixing 404 pages
The interface for tracking and fixing 404 pages

Domain-level redirects

If you have the Redirect Domain submodule enabled, you will also have the "Domain redirects" tab at your disposal. It enables developers and webmasters to redirect the entire domain to another one by specifying the original domain, the target domain, and the sub path.

The interface for creating domain-level redirects
The interface for creating domain-level redirects

Redirect settings

The Settings tab contains the default settings for the Redirect module, as well as for the functionality provided by the Global Redirect — another contributed Drupal module that used to exist separately but was merged with the Redirect module starting with Drupal 8.

The default settings are pretty sensible here. Some of the most important ones are:

Automatically create redirects when URL aliases are changed: With this feature enabled, your Drupal website's URLs get properly redirected any time changes are made to them.

Enforce clean and canonical URLs: Thanks to this feature, automatic redirects are made to the canonical address of any Drupal page. The process involves a good cleanup such as removing trailing slashes, ensuring the language prefixes are set, and more.

The module's settings tab (1)
The module's settings tab (1)

404 error database logs to keep: The default amount of 404 errors logged in the database is 10,000. Developers or webmasters might consider decreasing it if they need to save disk space.

The module's settings tab (2)
The module's settings tab (2)

It's great to know there is a Drupal module like this that helps content editors, SEO experts, and developers by allowing both simple manual redirects and more complex scenarios. The benefits of proper redirects for SEO are absolutely priceless.

This article is adapted from How to Boost SEO with URL Redirects in Drupal and is republished with permission from the author.