In Drupal 7, a module could implement hook_url_inbound_alter() and hook_url_outbound_alter() to rewrite URLs used in Drupal. The same effect could be obtained with path aliases. The only difference is that for path aliases that are someway dynamic, you would need a module that adds a path alias every time there is the need. That is what the Pathauto module does.

Is there any difference between the two approaches (implementing those hooks, and using path aliases)? Is there any reason to prefer one approach to the other one?
Is there any performance difference between the two approaches?

The only difference I can see is that with those hooks there could not be the need of accessing the database (depending on how the hooks are implemented). Is that the only difference, or are there more differences?

1 Answer 1


Using hook_url_outbound_alter() has some potential performance issues because it is executed by every single URL on a page via the url() function. This means a module could implement hook_url_outbound_alter() with some complex and slow code that is called 100's of times per page.

Also hook_url_outbound_alter() allows a link's $options, including its query string, to be altered, which is impossible to do to path aliases and a very useful feature. For example, I have altered internal RSS URLs to point to their respective Feedburner and iTunes URLs.

Conceptually, the Path module should be calling the hook_url_*_alter() hooks but it is probably slightly faster to have the drupal_get_path_alias() calls directly in url().

My personal conclusion is when possible use the built-in path system, but for most special circumstances you will have to use the hook_url_*_alter() hooks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.