[drupal-devel] [bug] patch: allow url_alias paths to have arguments

jhenry drupal-devel at drupal.org
Thu Jul 21 15:39:26 UTC 2005

Issue status update for 
Post a follow up: 

 Project:      Drupal
 Version:      4.6.0
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  jhenry
 Reported by:  jhenry
 Updated by:   jhenry
 Status:       patch

Currently, urls that use the url_alias table do not allow arguments. 
This is not desirable because it is useful to be able to specify
arguments on a script that is aliased without having to refer to it by
node number.

The code below replaces the drupal_get_normal_path() function in
common.inc to allow aliased paths to have arguments.

 * Given a path alias, return the internal path it represents.
function drupal_get_normal_path($path) {
  if (($map = drupal_get_path_map()) && isset($map[$path])) {
    return $map[$path];
  elseif (function_exists('conf_url_rewrite')) {
    return conf_url_rewrite($path, 'incoming');
  else {
    //look at each of the path components of $path and allow extra
components to be arguments
    //do a greedy search first for the largest paths
    if ($map && (strpos($path, '/') !== false)) {
      $newpath = clone($path);
      $args = '';
      while($path_end = strrpos($newpath, '/')) {
        $args = substr($newpath, $path_end).$args;
        $newpath = substr($newpath, 0, $path_end);
        //check to see if this new path exists in the path map
        if(isset($map[$newpath])) {
          return $map[$newpath].$args;
    //no alias was found, return the original path
    return $path;


More information about the drupal-devel mailing list