4.6.x bootstrap.inc drupal_get_path_alias($path)
4.7.x path.inc drupal_get_path_alias($path)
5.x path.inc drupal_get_path_alias($path)
6.x path.inc drupal_get_path_alias($path, $path_language = '')
7.x path.inc drupal_get_path_alias($path = NULL, $path_language = NULL)

Given an internal Drupal path, return the alias set by the administrator.


$path: An internal Drupal path.

$path_language: An optional language code to look up the path in.

Return value

An aliased path if one was found, or the original path if no alias was found.

2 calls to drupal_get_path_alias()
block_list in modules/block/block.module
Return all blocks in the specified region for the current user.
_statistics_link in modules/statistics/statistics.module
It is possible to adjust the width of columns generated by the statistics module.


includes/path.inc, line 108
Functions to handle paths in Drupal, including path aliasing.


function drupal_get_path_alias($path, $path_language = '') {
  $result = $path;
  if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
    $result = $alias;
  return $result;


fonant’s picture

The complementary function is drupal_get_normal_path().

crimsondryad’s picture

For example, if you used it like this:

$path = drupal_get_path_alias($_GET['q']);

Is that safe? Or should the $_GET be wrapped in check_plain() or another security function?

Dave Reid’s picture

The $path variable in this case must be properly escaped either with check_plain() or check_url() depending on how it is being output.

chrisjlee’s picture

Borrowed from this node:
Adding external files through drupal API: http://drupal.org/node/225868

Added to template.php:

*   Globe Runner SEO = GRS
*   Use your own namespace if you'd like!
*   @return String - Provides you with a clean url

function grs_get_path() {
	return strtolower( preg_replace( '/[^a-zA-Z0-9-]+/', '-', drupal_get_path_alias( $_GET['q'] ) ) );
Dave Reid’s picture

Or you could just use Pathauto.