2

I have a site example.com with a subdomain sub.example.com. In my apache config both domain and subdomain point to the same directory, containing the Drupal installation. That is as far as i went to set up a the subdomain.

The issue is, the main menu on sub.example.com uses the same menu and template as the main site. The links link to sub.example.com/node/1 instead of example.com/node/1, effectively creating a clone of the whole site on the subdomain.

How do i show the same menu, but have the links all link back to example.com/node/1

1 Answer 1

1

It will depend on your theme, but typically the menu array (e.g. $mail_menu in page.tpl.php) can be altered such that each menu item have the array element 'absolute' set to TRUE so that l() will generate the link with an absolute path.

For example, in a MYTHEME_preprocess_page() function:

/**
 * Override or variables into the page template.
 */
function MYTHEME_process_page(&$vars) {
  foreach ($vars['main_menu'] as $id => $menu_item) {
    $vars['main_menu'][$id]['absolute'] = TRUE;
  }
}

As long as $base_url is set to http://example.com, it should render the menu links to your original domain.

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.