Drupal URL Aliases and Redirects — Clean URLs with Pathauto and Redirect
In this tutorial, you'll learn how to manage URLs in Drupal using the Pathauto module for automatic URL aliases and the Redirect module for handling 301 redirects — essential skills for SEO-friendly site architecture.
What You'll Learn
- How URL aliases work in Drupal and why clean URLs matter for SEO
- Installing and configuring the Pathauto module for automatic alias generation
- Creating alias patterns for content, taxonomy, and user entities
- Using the Redirect module to manage 301 and 302 redirects
- Best practices for URL alias management on multilingual sites
Why It Matters
Default Drupal URLs like /node/123 are unhelpful for users and search engines. Clean URLs like /about-us/our-team tell visitors and Google what the page is about before they click. Beyond aesthetics, URL aliases affect search rankings, link sharing, and user trust. When you change a URL, the Redirect module ensures old links still work by automatically issuing a 301 redirect. Without proper URL management, you lose traffic from broken links and damage your SEO authority.
Real-World Use
A news site migrates from an old domain to a new domain. Every article URL changes. Using the Pathauto module, they set up new URL patterns matching their new structure. The Redirect module creates 301 redirects from every old URL to the corresponding new URL. Google's crawlers follow the redirects, transfer search equity to the new URLs, and the site maintains its search rankings through the Migration.
Learning Path
flowchart LR A[Text Formats] --> B[Webforms] B --> C[URL Aliases & Redirects] C --> D[Theme Anatomy] D --> E[Installing Themes] E --> F[Twig Templating] F --> G[Sub-themes] G --> H[Template Suggestions]
Understanding URL Aliases
A URL alias is a user-friendly path that maps to Drupal's internal path. When a Visitor accesses /about-us, Drupal internally resolves it to the node page node/5 and serves the content.
Internal path: node/5
URL alias: /about-us
Full URL: https://example.com/about-us
Drupal stores aliases in the url_alias database table:
# Query url_alias table via Drush:
drush sqlq "SELECT * FROM url_alias WHERE alias LIKE '/about%';"
# Example output:
# pid | source | alias | langcode
# 1 | /node/5 | /about-us | en
# 2 | /node/12 | /about/team | en
You can manually create aliases at Configuration > URL aliases > Add alias. Enter the internal path (node/5) and the desired alias (/about-us).
The Pathauto Module
Pathauto automates alias creation. Instead of manually typing aliases for every piece of content, you define patterns and Pathauto generates aliases automatically when entities are saved.
Installation
# Install Pathauto via Composer:
composer require drupal/pathauto
# Enable the module:
drush en pathauto pathauto_redirect
Pathauto depends on the Token module, which Composer installs automatically.
Configuration
Go to Configuration > URL aliases > Patterns. You see sections for each entity type: Content, Taxonomy terms, Users, and Custom blocks.
Content Patterns
Content patterns use tokens to build URLs. Here is a common pattern configuration:
# Content pattern:
pattern: '[node:content-type]/[node:title]'
# Result: /article/hello-world
# Result: /page/about-us
You can make patterns more specific:
# Pattern for Article content type only:
pattern: 'articles/[node:title]'
# Result: /articles/5-tips-for-drupal
# Pattern for Basic Page:
pattern: '[node:title]'
# Result: /about-us
# Pattern with date and category:
pattern: 'blog/[node:created:custom:Y]/[node:created:custom:m]/[node:title]'
# Result: /blog/2026/06/drupal-tutorial
Taxonomy Patterns
# Taxonomy term pattern:
pattern: '[term:vocabulary]/[term:name]'
# Result: /tags/drupal
# Result: /categories/tutorials
# Multi-level taxonomy path:
pattern: 'topics/[term:parent:parents:join-path]/[term:name]'
# Result: /topics/programming/php/drupal
User Patterns
# User page pattern:
pattern: 'users/[user:name]'
# Result: /users/admin
# Result: /users/john-doe
Token Variables
Pathauto uses tokens from the Token module. Here are the most useful ones for URL patterns:
Node tokens:
[node:title]— page title, lowercased and hyphenated[node:nid]— node ID number[node:content-type]— machine name of content type[node:created]— creation date[node:author]— author name[node:menu-link]— menu link path if in a menu
Taxonomy term tokens:
[term:name]— term name[term:tid]— term ID[term:vocabulary]— vocabulary machine name[term:parent]— parent term name[term:parents]— all parent terms joined
User tokens:
[user:name]— username[user:uid]— user ID[user:roles]— user roles
Date formatting:
[node:created:custom:Y]— four-digit year[node:created:custom:m]— two-digit month[node:created:custom:d]— two-digit day[node:created:custom:Y/m/d]— full date path
Managing Aliases
After Pathauto generates aliases, you can view and manage them at Configuration > URL aliases.
Bulk Update
If you change a pattern, existing aliases do not automatically update. You must regenerate them:
- Go to Configuration > URL aliases > Bulk generate
- Select which entity types to regenerate
- You can choose to delete old aliases before generating new ones
- Click "Generate"
Deleting Aliases
You can delete individual aliases from the URL aliases list page. Check the box next to an alias and select "Delete" from the bulk operations dropdown.
The Redirect Module
The Redirect module manages URL redirects. When a URL changes, you create a redirect from the old URL to the new one. The module automatically detects when an alias changes and offers to create a redirect.
Installation
# Install Redirect module:
composer require drupal/redirect
# Enable:
drush en redirect
Creating Redirects
- Go to Configuration > Search and metadata > URL redirects
- Click "Add redirect"
- Enter the source path (the old URL)
- Enter the target path (the new URL)
- Select the redirect status: 301 (Moved Permanently) or 302 (Found)
- Save
# Redirect configuration example:
redirect_source:
path: '/old-article-path'
redirect_redirect:
uri: 'internal:/node/123'
status_code: 301
language: en
Importing Redirects
For bulk redirects, import a CSV file:
- Go to Configuration > Search and metadata > URL redirects
- Click "Import"
- Upload a CSV with columns: source, target, language, status_code
source,target,status_code
/old-page,/new-page,301
/old-blog,/articles,301
/events,/upcoming-events,302
Automated Redirects from Pathauto
When you install both Pathauto and Redirect modules together, changing a node's URL alias automatically creates a redirect from the old alias to the new one. This prevents broken bookmarks and maintains SEO value.
# Pathauto settings for automatic redirects:
pathauto:
update_action: add_new
redirect_if_changed: true
Redirect Status Codes
Understanding HTTP redirect status codes helps you choose the right type:
301 Moved Permanently indicates the resource has permanently moved to a new URL. Search engines transfer ranking credit from the old URL to the new one. Use this for permanent URL changes.
302 Found indicates a temporary move. Search engines keep the old URL indexed and do not transfer ranking credit. Use this for temporary redirects like A/B testing or maintenance pages.
# Check redirect status with curl:
curl -I https://example.com/old-page
# Expected output includes:
# HTTP/2 301
# location: https://example.com/new-page
SEO Impact of Clean URLs
Clean URLs directly affect search engine rankings:
Readable URLs help users understand what the page is about before clicking, which improves click-through rates. Google's algorithm considers URL path as a ranking signal. Consistent URL structure helps Google crawl and index your site more efficiently. When URLs change, proper redirects preserve accumulated SEO authority.
URL Aliases for Multilingual Sites
On multilingual Drupal sites, each language can have its own URL alias for the same content:
# Example multilingual aliases:
# English: /about-us (node/5, langcode: en)
# French: /a-propos (node/5, langcode: fr)
# German: /uber-uns (node/5, langcode: de)
Pathauto patterns can incorporate language:
# Multilingual pattern:
pattern: '[node:langcode]/[node:content-type]/[node:title]'
# Result: /en/article/hello-world
# Result: /fr/article/bonjour-le-monde
Common Mistakes
Not installing the Redirect module alongside Pathauto: When Pathauto changes an alias without creating a redirect, the old URL returns a 404 error. Always install the Redirect module to get automatic redirects on alias changes.
Using duplicate aliases: Pathauto can generate the same alias for different content if titles are identical. Configure Pathauto to append a number when duplicates are detected.
Changing patterns without regenerating aliases: Updating a pattern only affects new content. Use the bulk generate feature to apply new patterns to existing content.
Forgetting language in patterns: On multilingual sites, aliases without language context can collide. Include
[node:langcode]in patterns to keep aliases unique per language.Using 302 instead of 301 for permanent moves: Using temporary redirects for permanent URL changes prevents search engines from transferring ranking credit to the new URL.
Practice Questions
How does Drupal resolve a URL alias like
/about-usto the actual content? What database table stores aliases?What is the difference between a 301 and 302 redirect, and when should you use each one?
How would you configure Pathauto to generate URLs in the format
/blog/2026/06/article-titlefor blog posts?Challenge: Plan a URL migration Strategy for a site restructuring from
/node/123URLs to/articles/seo-titleURLs. Define the Pathauto pattern, explain how to regenerate existing aliases, configure automatic redirects from old to new URLs, and describe how to verify that all redirects work correctly using a tool like curl.
FAQ
Mini Project
Goal: Set up automatic URL aliases with redirect management.
- Install Pathauto and Redirect modules via Composer
- Go to Configuration > URL aliases > Patterns
- Set content pattern to
[node:content-type]/[node:title] - Create an Article with title "Hello World" — verify alias is
/article/hello-world - Change the pattern to
blog/[node:title]and run bulk generate - Verify the redirect from
/article/hello-worldto/blog/hello-worldwas automatically created - Test the redirect with curl:
curl -I http://localhost/article/hello-world - Create a manual 301 redirect from
/old-pageto/new-page - Export the redirect list to CSV
What's Next
Now that you understand URL management, proceed to theme anatomy to learn how Drupal themes are structured. After that, explore installing and managing themes to customize your site's appearance.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro