What alternative methods are there for redirecting all page requests to the www version of a domain?
I know how to eidt the root .htaccess file but find that this method does not survive core updates.
Is there another way? Perhaps with a module?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityIt's always going to be better to do this with .htaccess, or in other web server config, but if you need to do it in php, put this at the top of settings.php:
if ($_SERVER['HTTP_HOST'] == 'example.com') {
header('Location:http://www.example.com' . $_SERVER['REQUEST_URI']);
exit();
}
instead of looking any module, i advice to add www in your CNAME record at your domain control panel.
I have two domains one of which I was using for development and the other was functional. I simply put a redirection in Index.php to redirect for the one domain.
You can change this behavior in your domain controller section of your cPanel