I wonder how to convert a URL path back to it's own node (node/nid). I wish to get the original node ID from a given path. e.g.

path = "news/my-news"

..and trace it back to get it's own original URL, e.g. 65. Please advise. Thanks.


3 Answers 3


GokulNK has already given the answer to use drupal_get_normal_path(). If you are working on any path alias that is different than the current path, use that.

If you want to get the non-aliased path of the current page/path, simply use $_GET['q']. Drupal path aliases are mod_rewrites but you still can find the internal path from $_GET['q']. For node paths or any structured paths and if you want to get the node ID or something, now don't explode('/', $_GET['q']) :)

Meet arg().

  • Aliased path: content/my-new-page
  • $_GET['q']: node/69
  • arg(0) = node
  • arg(1) = 69
  • drupal_get_normal_path('content/my-new-page') (Probably require some db trips unless cached)

You can use drupal_get_normal_path function.

Return value

The internal path represented by the alias, or the original alias if no internal path was found.


All the URl path are stored in database so you can configure it in admin/config/search/path whether your are using pathauto or writing your own url alises. Deleting from admin setting may convert a URL path back to it's own node (node/nid).

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.