What is the best way to forward visitors to my homepage to an external site but leave the backlinks accessible?

drupal.stackexchange https://drupal.stackexchange.com/questions/274699

  •  06-02-2021
  •  | 
  •  

Question

Maybe not distinctly a Drupal question, I have an older Drupal 7 site that I want to leave up for backlinks, but any new visitors I want to redirect to a new external website. So domain.com would redirect to newdomain.com but domain.com/node/6 is still accessible.

Update: Server is nginx and I don't have access to server settings and routes.

Était-ce utile?

La solution

It sounds like one thing you could do is edit the themes template.php file and do something like:

/**
 * Implements template_preprocess_html().
 */
function mytheme_preprocess_html(&$variables) {
  if (drupal_is_front_page()) {
    $url = 'http://newdomain.com';
    drupal_goto($url, ['external' => TRUE], 301);
    // perhaps alternatively you could use header();
  }
}

Outside of doing this at the web server level, it might be the smallest change to do it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à drupal.stackexchange
scroll top