I need to check if a url exists in a module that I am creating. How should I go about doing this? I tried to use a @get_headers() function with php, but sadly that doesn't work. I am wondering if there is a built in drupal function that I can use?


1 Answer 1


This is what fixed it:

if (!drupal_valid_path($path)) {
  // Not a system URL.
  if (!drupal_lookup_path('source', $path))  {
    // Not a path alias.
    // $path does not exist.

Where $path is a relative url.



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.