7.x system.api.php hook_url_inbound_alter(&$path, $original_path, $path_language)

Alters inbound URL requests.


$path: The path being constructed, which, if a path alias, has been resolved to a Drupal path by the database, and which also may have been altered by other modules before this one.

$original_path: The original path, before being checked for path aliases or altered by any modules.

$path_language: The language of the path.

See also


Related topics

1 function implements hook_url_inbound_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

url_alter_test_url_inbound_alter in modules/simpletest/tests/url_alter_test.module
Implements hook_url_inbound_alter().


modules/system/system.api.php, line 4328
Hooks provided by Drupal core and the System module.


function hook_url_inbound_alter(&$path, $original_path, $path_language) {

  // Create the path user/me/edit, which allows a user to edit their account.
  if (preg_match('|^user/me/edit(/.*)?|', $path, $matches)) {
    global $user;
    $path = 'user/' . $user->uid . '/edit' . $matches[1];


David Strauss’s picture

This replaces custom_url_rewrite_inbound() from Drupal 6.

DRippstein’s picture

From Dave Reid's comment at DrupalCoder that made this work for me:

custom_url_rewrite_inbound() or hook_url_inbound_alter() is run on DRUPAL_BOOTSTRAP_PATH (before most modules are loaded).

custom_url_rewrite_outbound() or hook_url_outbound_alter() is always run with DRUPAL_BOOTSTRAP_FULL (all modules loaded).

The trick is if you want to implement the inbound hooks, you have to make sure your module implements hook_boot() (can be just an empty function) so that it's loaded prior to the full bootstrap.

penyaskito’s picture

custom_url_rewrite_outbound was the drupal 6 solution for implementing this, and required hook_boot().
Implementing hook_url_inbound_alter or hook_url_outbound_alter don't require implementing hook_boot().

scottatdrake’s picture

There is a handy Drupal 6 contrib module that provides this hook:

stBorchert’s picture

See http://drupal.stackexchange.com/a/190279 for a way on how to do this in Drupal 8.

juliaset’s picture

I'm trying to use this hook along with the outbound hook to alter urls for a faceted search site. The outbound hook accommodates for query string parameters, however the inbound hook doesn't. What am I missing?