How do I create relative menu links in Drupal?

- Tags:

Sometimes you want direct a menu item in Drupal to a location using a relative link. You cannot use <front>/{location} because Drupal validates the link.
When you add a new link, the link is validated using menu_edit_item_validate(), it returns true when: 

  • the path is <front> (<front>/directory, or similar paths are excluded);
  • the path is an external path (the function url_is_external() returns TRUE);
  • the path is associated with a menu callback.

However you don't always want to specify an absolute URL.

So let's say I want to direct to another URL on the same domain. Drupal is running on http://www.example.com and I want to have a link to http://www.example.com/frontend

The drupal menu will link to: http://www.example.com/frontend

When you use https, you should enter https:/frontend in the path field for the menu item.