Remove aliasses from Database tables, any problems?

Created on 30 March 2025, 7 months ago

Problem/Motivation

Because I have specific pages which use multiple taxonomy terms, somehow 1000+ alliasses are made in my drupal system. I want to remove them the easiest way. They are not doubled alliasssen, but for every combination of taxonomy terms. So if you have a vocabulary fruit and vocabulary eatingtimes. I have all these aliasses, which sometimes do not even consist of content.
So apple/morning, apple/afternoon apple/evening, strawberry/morning, strawberry/afternoon, strawberry/evening.
I want to remove a lot of these aliasses from which the pages do not contain content.

Can I just remove them through removing them from the database tables:
- path_alias
- path_alias_revision
Is this ok? I tried VBO in Drupal 10, but this doesn't have an alias delete item, see https://www.drupal.org/project/pathauto/issues/3514448 🐛 "Delete URL Alias" action does not work with views_bulk_operations Active

Thanks for your reply in advance, greetings,

💬 Support request
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands Summit

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Summit
  • 🇳🇱Netherlands Summit

    Hi,
    This worked for me for a particular one, within PHPMYADMIN. Is this save
    DELETE FROM `path_alias` WHERE `alias` LIKE '%alias_name%';
    DELETE FROM `path_alias_revision` WHERE `alias` LIKE '%alias_name%';
    greetings,

  • First commit to issue fork.
  • 🇸🇮Slovenia miroslavstankov

    Hi,
    I think deleting aliases directly in phpMyAdmin (DELETE FROM path_alias WHERE alias LIKE '%apple%';) is risky. It doesn’t check if aliases are linked to nodes and could mess up Drupal’s cache, causing broken links or errors.
    A better approach i think is using a simple Drush script to safely delete only aliases not tied to nodes. Something like:

    $pattern = '/apple/%'; // Change to your pattern, e.g., '/strawberry/%'.
    $aliases = \Drupal::entityTypeManager()->getStorage('path_alias')->loadByProperties(['alias' => $pattern]);
    foreach ($aliases as $alias) {
    $path = $alias->getPath();
    if (preg_match('/^\/node\/(\d+)$/', $path, $matches) && !Node::load($matches[1])) {
    $alias->delete();
    echo "Deleted: " . $alias->getAlias() . "\n";
    }
    }

    I’d love to hear other solutions too if anyone has them!

Production build 0.71.5 2024