Drupal - How do I get the full URL of the current page?

Have you tried using request_uri()?

$_SERVER['HTTP_HOST'] . request_uri();

It should do the trick. I haven't tried it myself, and I may be off a bit, but I suggest you give a try. From JavaScript, you could use the window.location.href variable.


Here's how to get the absolute URL for the current page, using the Drupal API:

$current_url = url(current_path(), array('absolute' => TRUE));

If you need the extra (non-q) querystring parameters as well, you can use:

$current_url = url(current_path(), array('absolute' => TRUE, 
                                         'query' => drupal_get_query_parameters()));

You can use the following code.

global $base_root;
$current_url = $base_root . request_uri();
echo $current_url;

Tags:

Uri

7