What is the best way to forward visitors to my homepage to an external site but leave the backlinks accessible?
-
06-02-2021 - |
سؤال
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.
المحلول
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.
لا تنتمي إلى drupal.stackexchange