By analogduck on
I want to check each URL as it comes in. If the URL is http, I want to redirect the browser to https.
I have code that I believe will work and I really just need to know what script and/or function I should be inserting it into in order to make this magic work for every single URL that drupal renders.
Also, is this sort of thing possible to do in a module as opposed to hacking the core code?
My code sniplet I am intending to use is:
if (!$_SERVER['HTTPS'])
{
header('Location: https://www.mysite.com/');
exit;
}
This code and several other examples are referenced here and here.
Any clues gratefully accepted.
Comments
Where to insert URL redirect code
I got this to work successfully by injecting my code into includes/bootstrap.inc like so (between the tags labeled "// AnalogInsert"):
This works, however, I still don't know if it is an optimum hack. Is this the best place to put such code? Can I do this from a module?
-- AnalogDuck
"If at first you don't succeed, chainsaw juggling is probably not for you."
I'd set my base_url variable
I'd set my base_url variable to https://www.mysite.com in conf.php and add a rewrite rule to .htaccess.
--
Drupal services
My Drupal services