Drupal. Get path alias from current url without the installation's folder arguments

ozke picture ozke · Jun 8, 2010 · Viewed 24.6k times · Source

I'd like to retrieve the current page path alias without the installation's folder arguments. I'm using:

drupal_get_path_alias(request_uri())

But this returns installation/whatever/actual/path and I want to retrieve the actual/path only no matter what installation/whatever is.

Thanks in advance :)

Answer

ozke picture ozke · Jun 8, 2010

Found it. It was actually a mix of both suggestions:

$current_path = drupal_get_path_alias($_GET["q"]);

Thanks though.


Update: the previous solution doesn't always work

Someone suggested using an alternative method:

str_replace(base_path(), '', drupal_get_path_alias(request_uri(), 1));

But, is there any way of doing the same without using the slightly expensive str_replace?

Thanks