How to Boost SEO with URL Redirects in Drupal
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 know firsthand how important it is for them to be able to do redirects in a convenient way. Within the ImageX Drupal development team, we created this guide to managing URL redirects for Drupal sites.
Read on to discover:
- Why redirects are needed
- How to redirect a URL to another URL in Drupal in a couple of simple steps
- What other, more advanced options are provided by Drupal’s Redirect module
What are URL redirects and why are they important?
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.
Very simplified, when you call up page R, it tells you that the content is at S, and when it comes to browsers, they show the content of S right away.
- John Mueller, Senior Webmaster Trends Analyst at Google (John Mueller's randoms)
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.
Usability factors influence your SEO ranking as well. And, of course, 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, or so-called “link juice” should be transferred to the new page.
Examples of scenarios when you may need redirects
There are a variety of situations where you may need to redirect a URL, a group of them, or the entire domain, on a permanent or temporary basis. Here are some examples of these use cases.
- Especially if your website is content-heavy, it’s a great idea to do a content audit from time to time. As a result of the audit, some pages get merged and some get removed if they are no longer important. Luckily, simple redirects help you avoid broken links.
- The word “typo” may send chills down the spine of a marketing manager or content editor, especially if this typo has been made in the URL of an important piece of content or, still worse, on printed advertising. Redirects come to the rescue!
- Sometimes, you need to temporarily redirect a page because you are running a promotional campaign.
- Users may often type in specific URL paths that do not exist on your site — for example, they may be using some typically misspelled words. It’s a great idea to forward them to the appropriate pages of your website.
- When you are performing website maintenance work, it’s a good practice to temporarily send users to a page with a message about it.
- Rebranding often involves changing your domain, which means all your pages need to be permanently forwarded to their new addresses so that your users (and Google) arrive at the right places.
- Sometimes, businesses need to merge multiple websites into one. Some of the pages will need permanent redirects.
When websites switch from the HTTP to the HTTPS protocol, which is a standard today, their pages will also need to be forwarded to their secure versions.
Users may type in URLs with or without the “www” prefix, with or without a trailing slash, and so on. Duplication also often happens with dynamic URLs that include category tags, parent tags, session IDs, and more. The meta "canonical" tag is one of the ways to tell Google which page is canonical or the most relevant and important among all the duplicates. Google will then crawl the canonical page more often and its duplicates less often.
How to create URL redirects in Drupal
URL redirects for Drupal websites can be made on the server, but this requires technical skills. We will share more universally accessible ways to forward one URL to another. 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 260,000 Drupal websites.
Module installation instructions
The highly recommended way to install modules on websites using Drupal 8 or higher is via Composer:
composer require drupal/redirect
Alternatively, there is the option to download the module from drupal.org as a tar.gz or zip file and install it via the Extend tab of your Drupal admin dashboard. However, this is not a preferred method.
The module comes packed with 3 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.
Getting started with the Redirect module’s user interface
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.
How to create a redirect in 3 simple steps
To create a simple redirect on your Drupal website, click “Add redirect” on the URL Redirects tab and do these 3 things:
Step 1: Type the old URL in the “Path” field. This is only the path after the domain (e.g. redirect/me).
Step 2: Type the new URL in the “To” field. Use a relative internal path (e.g. /my-page) or an absolute external path (e.g. https://web-address.com/their-page).
Step 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:
- The 301 code means the page is moved to a new address permanently. Use it when you remove or merge a page, want to fix a typo, etc.
- The 302 code means the page is moved to a new address temporarily. Use it when you need a redirect during a temporary promotional campaign, when your Drupal website is under maintenance, etc.
Once the URL path fields are filled out and the status is selected, click “Save” at the bottom of the page.
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.
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 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 as follows:
- 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.
- 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.
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 UX and SEO are absolutely priceless. If you need help using the module or performing an audit of your Drupal website’s URLs, contact our Drupal team, and let’s chat.