Credits & Thanks
Thank you to:
- Moshe Weitzman (moshe weitzman) for creating this module
- Oleksandr Dekhteruk (pifagor)
- Sascha Grossenbacher (Berdir)
- Dave Reid
- The large number of other contributors to this module!
SEO Training Camp: https://moz.com/learn/seo/redirection
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 from old URLs to new URLs on your website. 301 redirects 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 used to be 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
- Install the Redirect module on your server. (See this section for more instructions on installing modules.)
- Go to the Extend page: Click Manage > Extend (Coffee: “extend”) or visit https://<yourDrupalSite.dev>/admin/modules.
- Search for the Redirect module in the search field:
- Select the checkbox next to “Redirect” and "Redirect 404" and click the Install button at the bottom of the page.
If necessary, give yourself permissions to use the Redirect module.
- Click Manage > People (Coffee: “people”) and click into the Permissions tab. Or go to https://<yourDrupalSite.dev>/admin/people/permissions.
- Select the appropriate checkboxes under the “Redirect” section.
- Click the Save permissions button at the bottom of the page.
Configure the Redirect module
- 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.
- The default settings are usually adequate, so make sure your settings match the image above.
- Select the appropriate checkbox next to Automatically create redirects when URL aliases are changed.
- Select the checkbox for Retain query string through redirect.
- Select “301 Moved Permanently” from the Default redirect status drop-down.
- Select the checkbox Enforce clean and canonical URLs.
- Select “10000” from the 404 error database logs to keep drop-down
- 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.
- 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.
- Click the +Add redirect button.
- Enter the From and To URLs in their respective fields:
- From is the old URL that is broken.
- 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://.
- Select “301 Moved Permanently” (or one of the other options as suited to the situation) from the Redirect status drop-down menu.
- Click the Save button.
Now, when someone visits the old URL, they’ll be automatically redirected to the new one.