Blog/ How to add 301 and 302 URL redirects in Drupal?

In this article, you will be learning how to add 301 and 302 redirects in Drupal. The 301 redirect lets search engines know that the page is removed permanently, while the 302 lets them know the page is removed temporarily. Both of them send the user and search engine to a different URL.

The only pre-requisite for this is that you must have admin rights.

First, we need to install the redirect module.

Installing Redirect Module

  1. Start by clicking on Extend and then on + Install new module.extend in Drupal
  2. Paste this URL in the box: https://ftp.drupal.org/files/projects/redirect-8.x-1.5.tar.gz. Proceed by clicking on Install.url in Drupal
  3. After the module installs you will see this message. Proceed by clicking on Enable newly added modules.installation complete in Drupal
  4. Search for redirect in the search box. Check the box beside Redirect and click on Install.install in Drupal
  5. You will have successfully installed the Redirect module.

Adding 301 and 302 redirects

  1. Go to Configuration and proceed by clicking on URL redirects under Search And Metadata.configuration in Drupal
  2. Click on + Add redirect.add redirect in Drupal
  3. Enter your old URL in the Path box, and the new URL in the To box. Select either 301 or 302 redirect from the Redirect status drop-down menu. We are choosing 301.add url in Drupal
  4. Proceed by clicking on Save.save in Drupal
  5. Your redirect will be saved.redirect saved in Drupal
  6. Now search for your-site/old-url, but replace your-site with the name of your website. You will be redirected to the newly set URL.new url in Drupal
 
Ready to get started?REQUEST A QUOTE