Skip to content

How to add a URL redirect in Drupal

To add a URL redirect in Drupal, install the Redirect module, go to Administration → Configuration → Search and metadata → URL redirects and select Add redirect. Enter the old path in Path, the new page in To, choose 301 Moved Permanently and save.

Redirect checkerUpdated 3 min read

Drupal core doesn't include redirects. The steps below follow the Redirect module's README on Drupal.org. Its project page lists it as working with Drupal 10 and 11.

Install the Redirect module

  1. Add the module with Composer from your site's root folder: composer require 'drupal/redirect'. The project page shows the same command with the current version.
  2. Go to Administration → Extend, tick Redirect and install it.
  3. Make sure your role has the Administer redirects permission. The URL redirects page needs it.

If your host doesn't give you Composer, ask them how they want contributed modules added.

Add a redirect

  1. Go to Administration → Configuration → Search and metadata → URL redirects (/admin/config/search/redirect).
  2. Select Add redirect.
  3. In Path, enter the old path without the domain, for example old-menu.
  4. In To, start typing the title of a piece of content and pick it from the list. You can also enter an internal path such as /node/12, an external URL such as https://example.com, or <front> for the home page.
  5. Choose the Redirect status. The module's settings make 301 Moved Permanently the default.
  6. Save.

Once it's saved, the redirect also appears in the URL redirects section on that content's edit page, so editors can see which old addresses point to it.

Which status to choose

The form lists several 3xx codes. For a page that has moved, keep 301: the HTTP standard, RFC 9110, says it means the page has a new permanent address and links ought to use it. 302 Found and 307 Temporary Redirect are for moves you'll undo, such as a seasonal page.

Check it works

Log out, or use a private window, and open the old path. Then paste the full old address into the checker below. It shows each hop and flags any that isn't a 301 or 308.

Redirect checker

Open the full tool

If you see two hops, for example http to https and then your Drupal redirect, that's the server's rule running first. It's fine, but point links you control at the final https address. See redirect chains.

Every time an editor changes a page's URL alias, the old alias stops working unless something redirects it. The Redirect project page recommends Pathauto, which can create those redirects automatically when an alias changes.

The Redirect module also has two optional sub-modules listed on its project page:

  • Redirect 404 logs paths that returned "not found" and lets you create a redirect from the log. It's the quickest way to catch old links people still follow.
  • Redirect Domain adds wildcard and whole-domain redirects.

The module also keeps one address per page: it redirects alternative URLs, such as the unaliased /node/12 path, to the page's alias.

When a redirect doesn't work

  • Nothing happens. Check the Path has no leading domain and matches what people type, then clear Drupal's caches and test again.
  • You see a loop. A redirect points at a path that redirects back, often after aliases have been swapped. The checker shows the loop hop by hop.
  • It works for you but not for others. Test logged out, the way visitors arrive.

For redirects outside Drupal, see how to redirect with .htaccess or how to redirect a domain.

Sources

Questions

Does Drupal have redirects built in?

Not in core. The contributed Redirect module adds them, and the project page lists it as working with Drupal 10 and 11.

Which status code does the Drupal Redirect module use?

301 Moved Permanently by default, set in the module's settings. You can choose another code for each redirect on its form.

How do I stop changed URL aliases breaking links?

Install Pathauto alongside Redirect. The Redirect project page recommends it because it can create redirects automatically when an alias changes.