TL-DR: My problems all emerged from the "Auto-redirect to Base Url" config messing up visits to http. I've fixed it and now I'm praying to the google gods they re-crawl the site ASAP to get everything out of the 'really really bad links' bin...
OK, so after digging a bit I believe I found the cause of the mess
1. Why did Google behave so strongly?
There is a config setting in Magento 1x
System > Configuration > 'Web' (left side tab) > 'Url Options' (right side tab).
Auto-redirect to Base Url > Yes/No
This makes all urls that do not exactly match (including the protocol) what Magento expects a url to look like, to redirect to the home page (base_url).
Unfortunately this setting is protocol agnostic illierate. Meaning, while this setting was enabled, right after I switched everything to https:// all the old http:// urls being visited by webcrawlers redirected them to the home page.
If you think this is a bug, good. So do I.
This is (most likely) the cause that made the switch backfire so heavily by Google dumping on us...
Unfortunately this broke site crawling on the first day. It's likely Googlebot saw this and threw all the links it crawled on that day in a bin of 'bad links'
I have since changed this to No.
2. What can I do to survive this mess?
sigh, fix it... and hope it will somehow recover. But the old http urls had been in good standing for so long; and high up enough in the results; that it will take time to get that back methinks.
I don't know how long Google takes to re-crawl links that it previously thought had 'bad content' ... if someone can point me to an action that I need to do to tell GoogleBot that "Hey I've fixed this, go crawl them again ASAP", please let me know. (yes, I've updated the sitemaps etc to be correct, read on)
3. Is there a module that makes Magento frontend obey "use secure on frontend"?
I didn't find one, so I had to dig through the code and figure it out. The Classes of interest are:
Mage_Core_Model_Store (this is the url factory)
Thankfully all of these classes use getBaseUrl() in Mage_Core_Model_Store so, no need to change these:
Mage_Core_Model_Url
Mage_Catalog_Block_Category_View (makes link rel canonical for category)
Mage_Catalog_Block_Product_View (makes link rel canonical for product)
So I only needed to modify App/code/core/Mage/Core/Model/Store.php
(I made a module out of it, but for testing you can just copy it over to /App/code/local/Mage/Core/Model/Store.php and apply the changes there. Do not overwrite core files in-place)
(This is the diff that Netbeans makes, sorry...)
--- a/<html>Store.php (<b>Today 1:06:57 μμ</b>)</html>
+++ b/<html><b>Current File</b></html>
@@ -585,6 +585,9 @@
*/
public function getBaseUrl($type = self::URL_TYPE_LINK, $secure = null)
{
+ if ($this->getConfig('web/secure/use_in_frontend')) {
+ $secure = true;
+ }
$cacheKey = $type . '/' . (is_null($secure) ? 'null' : ($secure ? 'true' : 'false'));
if (!isset($this->_baseUrlCache[$cacheKey])) {
switch ($type) {
Expected effects: Since the 'Auto-redirect 'option is now disabled, http links will be valid and will not be redirected. https links will also be valid. The visitor will be seeing https in all img src, a href, link rel, etc. and navigate to https on their next click inside the site. (and stay at https)
I have made certain that none of the content has hardcoded img src with http:// on any products/categories/blocks. They all use either {{media ...}} or the fallback <img src=//domain.tld/foo"> thank you MySQL REPLACE()
This also generates https link rel canonical, so there's no duplicate content issues. and the sitemaps are generated with https as well. I cannot think of anything else I might need to fix to have the effect there but since Mage::getBaseUrl redirects to Mage::app()->getStore()->getBaseUrl(), and that's the class I modified, I think I'm covered (?).
My Intent is to let it run like this for a couple of months so whatever engine visits the http site will still be able to do so and switch their canonical links to https. And then switch it all over to https
Issues: visitors of http:// pages cannot use Ajax to a https:// target, this makes the search box that has ajax auto-complete not work for the visitor's first page load. (I'm hoping Googlebot does not care about this since it's js... am I wrong? please let me know)
Since all links have https, the visitor's next page load will have ajax working fine. I also had to change the main navigation menu from ajax to static, but I can live with that.
I initially thought I'd have trouble with onepagecheckout because of this, but because the user will have to switch to https long before they reach that page, it is not an issue.
I do not think there's any other ajax elements in the page anywere else.. this site uses a pretty simplistic theme, so no auto-scroll categories or other autoloaders like that.
I'm posting this in the hopes that it might help anyone that made similar mistakes I did when switching from http to https.
This should not be needed for any other scenario.
If you're building a new site on https from the get-go, there will not be any old crawler history on old http links to worry about.