Create 301 and 302 URL Redirections in Drupal
Websites change frequently and you often need to move or change URLs. Whenever you make a change, you’ll need to safely redirect the old URLs to the new URLs.
In this tutorial, I’m going to show you how to create 301 and 302 redirects for your Drupal site.
Step #1. Install and enable Redirect module
Download the Redirect module from this page.
- Install and enable the module.
Step #2. Create an internal redirect
- Go to Configuration
- Look in the Search and metadata section for “URL redirects”.
- Click “Add redirect”.
Fill in the settings:
- Enter the old URL into the From field
- Enter the new URL into the To field
- Leave the Enabled as checked.
Optionally, inside “Advanced options”, change the redirect status according to your needs.
The most common are:
- Default (301): for permanent redirects. For SEO purposes, to tell Google to index the new URL.
- 302 Found: for temporary redirects
- Click “Save” when you’re done.
Step #4. Create an external redirect
You can also create redirects pointing outside your site.
For example, I want to use the link www.mysite.any/go-out to redirect to www.google.com with the settings below:
Step #5. Test the redirect
Go to your www.mysite.any/old-url to confirm is indeed redirecting to www.mysite.any/new-url.
Step #6. Number of times a redirect is being used
You can track the number of times a redirect is being used, by checking the statistics in “Count” column from the URL redirects list:
For Drupal 7. It would be very helpful to add how to configure the redirect module and explain why one would pick certain options and why it is helpful to check certain boxes – specifically Automatically create redirects when URL aliases are changed.
This is hugely helpful and we did not know about it for 2 years.
Also could you talk about Allow redirects to be saved into the page cache.?
Why would you not do this if you are caching pages for anonymous users?