Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Private content 3.1.0 Minor update available for module private_content (3.1.0). Release: Webform Analysis 2.0.0 Major update available for module webform_analysis (2.0.0). Usage Milestone: Focal Point Module focal_point crossed 1,000 active installs. Release: Form Style 2.0.1 Minor update available for module form_style (2.0.1). Release: Direct Upload Media Image 1.1.3 Minor update available for module dumi (1.1.3). Release: Changelogify 1.8.1 Minor update available for module changelogify (1.8.1). Release: Block Content Visibility 1.0.0 Initial release available for module block_content_visibility (1.0.0)! Release: Opensolr Search 4.3.1 Minor update available for module opensolr_search (4.3.1). Release: Opensolr Search 4.3.0 Minor update available for module opensolr_search (4.3.0). Module Revived: Commerce Shipping Order Percentage 1.2.0 Module commerce_shipping_order_percentage updated after 11 months of inactivity...

URL Rewriter

No security coverage
View on drupal.org

Bulk-replace URLs in the database from an admin UI. Handles menu links, entity link fields, rich-text body, and file URLs. Purpose-built for teams syncing production databases into lower environments.

What it does

URL Rewriter helps you bulk-replace URLs stored in your Drupal database. It can handle menu links, entity link fields, rich-text content, file URLs, and Redirect module destinations. You can define replacement rules from the admin UI, preview the changes before applying them, and review the results through an audit log.

Why you'd want this

If you regularly sync your production database to a lower environment such as DEV, UAT, or local, you may have come across the same problem: menus, buttons, CTAs, and other links continue to point to the production site.

This can be especially confusing during QA, and there is always a risk of accidentally sending an editor or tester back to production. Existing contrib modules such as Pathologic and URL Replace Filter mainly handle URLs in rich-text content at render time. They don't update URLs stored in menu links, link fields, file references, or other database fields.

URL Rewriter addresses this by updating the stored URLs directly in the database, making it useful as a step in your database-sync workflow.

Features

  • Manage replacement rules from the admin UI — no custom code or Drush scripts are required.
  • Supports menu links, entity link fields (including *_uri columns discovered from the database schema), rich-text body fields, file base URLs, and Redirect module destinations.
  • Preview changes with a dry run before applying a rule.
  • Uses Drupal's Batch API to handle large databases efficiently, including databases with hundreds of thousands of rows.
  • Automatically handles revision tables so rewritten URLs are also reflected when editing revisionable content.
  • Provides an audit log with an overall count for each rule and sampled rows for additional context.
  • Includes Drush commands that can be used in CI/CD and database-sync workflows.
  • Allows you to exclude specific entity types and fields from individual rules.
  • Provides hook_url_rewriter_targets_alter so other modules can modify or extend the list of targets.

Requirements

  • Drupal 10.4 or 11
  • PHP 8.3+

URL Rewriter has no hard dependencies. The Redirect module is optional. If it is installed, URL Rewriter can also update the destination URLs stored by Redirect.

Quickstart

composer require drupal/url_rewriter
drush en url_rewriter

Once the module is enabled, go to Configuration → Development → URL Rewriter and create your first replacement rule.

Drush

Command Purpose drush url-rewriter:list List all configured rules drush url-rewriter:preview [rule] Preview the number of records that would be changed drush url-rewriter:run [rule] Run the URL replacement drush url-rewriter:audit --limit=N View recent sampled audit log entries

You can also include the command in your existing database-sync or deployment workflow:

drush url-rewriter:run

Known limitations

  • No revert or undo functionality yet. Take a database backup or snapshot before running a replacement where restoring the database may be difficult.
  • URL matching currently supports plain-text strings only.

Similar modules

  • Pathologic — rewrites URLs in rich-text content using a text filter at render time.
  • URL Replace Filter — provides URL replacement through a text filter, with a similar rich-text-focused scope.

URL Rewriter complements these modules rather than trying to replace them. If you need URLs to be rewritten dynamically when rich-text content is rendered, Pathologic can be a good fit. If you need the URLs stored in your database to match the current environment — including menus, link fields, file URLs, and revisions — URL Rewriter is designed for that use case.

FAQ

Does it affect API / JSON output?

Yes. URL Rewriter updates the values directly in the database, so anything that reads those values will get the updated URLs. This includes HTML, JSON:API, sitemaps, feeds, email templates, and other integrations.

If there are URLs that should not be changed, such as a webhook callback or a URL used by an external service, you can exclude the relevant field using the rule's Excluded field names setting.

Is it reversible?

No, not as of now. We recommend taking a database backup or snapshot before running a replacement against an environment that cannot be easily restored.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Aug 2026
Latest release
6 hours ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
1.0.0-alpha1 Pre-release 10–11 Aug 29, 2026
1.0.x-dev Dev 10–11 Aug 29, 2026