The Redirect Module

easy redirect module install and configuration

https://www.drupal.org/project/redirect

Credits & Thanks

Thank you to:

About the Redirect Module

The Redirect module redirects visitors from old URLs to new URLs. When you move a piece of content to another section of your site or inadvertently change the URL, this module can really help.
    
The Redirect module creates 301 redirects which help your SEO by making sure that any URL that ranks in Google will still resolve when a visitor arrives. If you don’t install this module, you will have to regularly look for any URLs that have changed and fix them.

This module highlights the power of Drupal, automating what was once an arduous and ongoing SEO chore. Thanks to the power of Drupal and the Redirect module, fixing links is a much less frequently needed task.

Install and Enable the Redirect Module

  1. Install the Redirect module on your server. (See this section for more instructions on installing modules.)
     
  2. Go to the Extend page: Click Manage > Extend (Coffee: “extend”) or visit https://<yourDrupalSite.dev>/admin/modules.
     
  3. Search for the Redirect module in the search field:

    redirect module install for drupal 9
     
  4. Select the checkbox next to “Redirect” and "Redirect 404" and click the Install button at the bottom of the page.

Permissions

If necessary, give yourself permissions to use the Redirect module.

redirect module permissions for drupal 9
  1. Click Manage > People (Coffee: “people”) and click into the Permissions tab. Or go to https://<yourDrupalSite.dev>/admin/people/permissions.
     
  2. Select the appropriate checkboxes under the “Redirect” section.
     
  3. Click the Save permissions button at the bottom of the page.

Configure the Redirect module

  1. Visit the Redirect Admin page: Click Manage > Configuration > Search and metadata > URL redirects > Settings (Coffee: “url redirect” then click the Settings tab) or visit https://<yourDrupalSite.dev>/admin/config/search/redirect/settings.

    redirect module configuration settings drupal 9
     
  2. The default settings are usually adequate, so make sure your settings match the image above.
     
    1. Select the appropriate checkbox next to Automatically create redirects when URL aliases are changed.
    2. Select the checkbox for Retain query string through redirect.
    3. Select “301 Moved Permanently” from the Default redirect status drop-down.
    4. Select the checkbox Enforce clean and canonical URLs.
    5. Select “10000” from the 404 error database logs to keep drop-down
  3. If you changed anything, click the Save configuration button at the bottom of the page.

How to create a manual redirect

The Redirect module also allows you to create manual redirects. If you move content, put the wrong URL on some printed advertising, or you’re migrating content, this is an invaluable function to understand.

Note: Creating a manual redirect isn’t necessary right now. However, it’s an essential skill for a growing site, so I’m covering it here.

  1. Go to the URL Redirects page: Click Manage > Configuration > Search and metadata > URL redirects (Coffee: “redirects”) or visit https://<yourDrupalSite.dev>/admin/config/search/redirect.
     
  2. Click the +Add redirect button.

    add a rule redirect in drupal 9
     
  3. Enter the From and To URLs in their respective fields:
     
    1. Path is the old URL that is broken.
    2. To is the new URL. If it’s a link on your site, you can use just the path beginning with the /. For example: /your/path/here. If it’s an external URL, put the entire URL including the https://.
       
  4. Select “301 Moved Permanently” (or one of the other options as suited to the situation) from the Redirect status drop-down menu.
     
  5. Click the Save button.

Now, when someone visits the old URL, they’ll be automatically redirected to the new one.

 

Did you like this walkthrough? Please tell your friends about it!

facebook icon twitter social icon linkedin social icon