A Drupal redirect is a way to send website visitors from one URL to another, assisting users in reaching the correct destination after any changes in links. It also helps prevent your website from URL loss and maintain current rankings on SERPs.
Understanding the importance of managing Drupal redirect, LitExtension – The #1 eCommerce Migration Service has crafted this guideline to walk you through:
- Different types of Drupal redirect
- Common scenarios you need to redirect Drupal website
- How to create 301 redirects in Drupal Apache
- How to create redirect with drupal redirect module
- Troubleshoot common errors while performing Drupal redirect
Let's get started!
Drupal Redirect – All You Need to Know
Different types of Drupal redirect
Drupal offers several types of redirects, each serving a specific purpose for managing URL changes and improving website performance. Understanding these types is essential for selecting the right redirect method based on your goals. Below are the most common types of Drupal redirect and their use cases.
1. 301 Redirect (Permanent redirect)
This type of redirect indicates that a page has been permanently moved to a new URL. It is the most SEO-friendly option because it transfers the page's ranking power to the new location. You should use a 301 redirect when merging pages, updating URLs, or moving your site to a new domain.
2. 302 Redirect (Temporary redirect)
A 302 redirect signals that the move is temporary and that the original URL will be restored later. This type of redirect is useful for short-term promotions or A/B testing, as search engines do not pass link equity to the new URL.
3. 307 Redirect (Temporary redirect with method retention)
A 307 redirect is similar to a 302 but maintains the original request method (e.g., POST). It is ideal for ensuring that forms, search queries, or API calls are processed correctly without altering the request behavior.
4. Meta Refresh Redirect
This is a client-side redirect that automatically forwards users to a new page after a few seconds, typically seen in “If you are not redirected in five seconds, click here.” Although it is often used for announcements or countdown pages, it is less SEO-friendly than server-side redirects like 301 or 302.
By understanding these types and their functions, you can effectively manage URL changes, maintain SEO value, and improve user experience on your Drupal site.
When should you use Drupal redirect?
Using Drupal redirect at the right time is crucial for maintaining website performance, SEO rankings, and user experience. Here are the most common scenarios where redirects are necessary:
- Migrating from old URLs to new URLs: When you change page slugs or restructure your site, create redirects from old URLs to new ones. This practice preserves search engine rankings and prevents broken links.
- Fixing 404 errors: If pages are deleted or moved, set up redirects to relevant pages. This prevents users from landing on error pages and maintains a smooth browsing experience.
- Migrating from HTTP to HTTPS: When switching to HTTPS for better security, set a site-wide 301 redirect from all HTTP pages to their HTTPS versions. This ensures users and search engines access the secure version of your site.
- Redirecting duplicate URLs to canonical URLs: To avoid duplicate content issues, redirect similar pages (e.g., with and without “www” or trailing slashes) to a single canonical version. This helps search engines consolidate page authority.
- Promotional or campaign-specific URLs: Use redirects for short, easy-to-remember URLs that point to longer, complex URLs. This is useful for marketing campaigns and social media promotions.
- After a website migration: If you migrate your site to a new platform or update its structure, use Drupal redirect to guide visitors and search engines from old URLs to new pages.
Seamless SEO Migration & 301 Redirects
Maintain your SEO effort during the Drupal Migration with LitExtension.
How to Create 301 Redirects in Drupal Apache
Creating 301 redirects in Apache is a server-level solution that is fast and efficient. This method is ideal for handling permanent redirects, especially when you are restructuring your site or moving pages. Follow these steps to set up a 301 redirect for your Drupal site using Apache.
1. Step 1. Locate the .htaccess file
- Navigate to your Drupal website’s root directory.
- Find the .htaccess file. This file controls how Apache handles redirects and other settings.
- If you cannot see it, enable the option to view hidden files in your file manager or FTP client.
2. Step 2. Find the following command in your .htacces file
# Various rewrite rules.
RewriteEngine on
# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /drupal
RewriteBase /
3. Step 3. Add 301 redirect rules
Now, you can add as many 301 redirect rules after the previous lines. Remember to follow this format to make sure your command works.
#custom redirects
RewriteRule ^old_URL_path$ http://example.com/new/path [R=301,L]
#end custom redirects
Please replace:
- “old_URL_path” with the path to your old URL
- “http://example.com/new/path” with the new URL you want to direct to.
4. Step 4. Save your changes and clear Drupal cache to ensure the new redirects take effect immediately.
How to Create Redirect With Drupal Redirect Module
Besides using Apache to create Drupal redirect, you can leverage different tools such as the Drupal Redirect module. It is a powerful tool for managing redirects directly within your Drupal site without editing server files.
Follow these steps to install, configure, and use the module for creating redirects.
1. Step 1. Install the Drupal Redirect module via Composer
- Use the following line command to install the Drupal Redirect module on your website: composer require drupal/redirect
- Now, you'll be able to find the module settings by navigating to “Configuration” > “Search and Metadata” > URL Redirects.
2. Step 2. Create a new redirect
- In the Redirect module panel, click the “Add redirect” button.
- Then, fill in the required information (marked with a red asterisk), including:
- Path: Your old URL path.
- To: The new URL path that you want to redirect to.
- Redirect status: Choose either “301 Moved Permanently” or “302 Found” from the drop-down list.
- Finally, click “Save” to finish adding.
If you have more than one URL that you want to redirect, please repeat this step as many times as you wish.
3. Step 3. Perform additional settings if needed
After creating Drupal redirect, you can switch to the “Settings” tab. Here, you'll see two essential options for further SEO enhancement.
- Automatically create redirects when URL aliases are changed: Enable this setting to maintain a clean website structure during internal link updates. When you modify a page alias, the system will automatically create a redirect from the old URL to the new one.
- Enforce clean and canonical URLs: Redirects users to the canonical version of a page, preventing them from accessing URLs like “/node/123”.
That's how easy it is to create redirects using the Drupal Redirect module.
Troubleshoot Common Errors While Performing Drupal Redirect
When setting up Drupal redirects, you may encounter issues that prevent them from working correctly. The table below outlines some common errors along with their solutions to help you quickly resolve these problems.
Error | Solution |
Redirect loop | - Check for conflicting rules in the .htaccess file or Drupal redirect settings. - Verify that canonical URL settings are configured correctly. |
404 error after setup | - Confirm that the source URL matches the exact path (e.g., no trailing slashes). - Ensure the redirect module is enabled and properly configured. |
Redirect module not working | - Check that the Redirect module is properly installed and active. - Verify user permissions to manage redirects. |
Duplicate redirects causing conflicts | - Use the URL Redirects admin page to review existing redirects. - Delete duplicate or overlapping redirects. |
Wildcards not functioning correctly | - Use the correct syntax when creating pattern-based redirects. |
Canonical URLs not enforced | - Enable the Enforce Clean and Canonical URLs option under Redirect module settings. - Check for conflicts with other modules like Pathauto or Global Redirect. |
Other pro tips for troubleshooting Drupal redirect:
- Always clear Drupal caches after adding or modifying redirects.
- Use browser developer tools or online redirect checkers to inspect redirect chains.
- Regularly audit your redirects to remove outdated or conflicting rules.
Drupal Redirects – FAQs
When should I use a redirect?
You can use redirects in Drupal for scenerios such as:
- Changing URLs: When you update a page slug or move content to a new path.
- Fixing 404 errors: Redirect users from deleted pages to relevant alternatives.
- Migrating from HTTP to HTTPS: Secure your site with a site-wide redirect.
- Consolidating duplicate content: Redirect multiple versions of a page to a single canonical URL.
What is the purpose of a redirect?
The primary purpose of a redirect is to guide users and search engines from one URL to another. Redirects ensure that:
- Visitors reach the correct pages even if URLs change.
- SEO rankings are preserved during website updates or migrations.
- Duplicate content issues are resolved, enhancing search engine performance.
What is the benefit of redirection?
The key benefits of implementing Drupal redirect include:
- Improved SEO: Retain page authority and search engine rankings during URL changes.
- Better user experience: Prevent users from landing on broken pages (404 errors).
- Enhanced security: Safely redirect from HTTP to HTTPS.
- Simplified maintenance: Easily manage URL changes without breaking internal links.
How to create Drupal redirect?
You can create redirects in Drupal following these steps:
1. Step 1. Install Drupal Redirect module
2. Step 2. Create a new redirect
3. Step 3. Perform additional settings
Final Thoughts
In conclusion, managing Drupal redirect effectively is essential for maintaining a smooth user experience and preserving SEO rankings during website changes. Whether you use the Redirect module or configure redirects through Apache, it’s crucial to choose the right method based on your needs.
If you like this article, please don't forget to check out other eCommerce articles on our website for more expert tips and insights.