Sitemap generating http links on https site when cron is set run through UI cron settings

Created on 2 March 2023, almost 2 years ago
Updated 20 July 2024, 5 months ago

When a site uses https redirects through .htaccess, the urls generated in the sitemap are set to http rather than https if you instruct the module to regenerate sitemaps through the drupal cron UI.

When you click any of the "generate" buttons in Simple XML Sitemap, the links return to https. Even when you click the "Run Cron" button in the UI, the sitemaps regenerate as https. Even running `drush cron` at the command line regenerates https links on the sitemaps. It's only when you have cron set to run through the "Run cron every" setting on the cron page do the sitemaps generate http. It's very strange.

Workaround 1: Default Baase URL

You can set the "Default base URL" in the Simple XML Sitemap configuration. This should be sufficient for many use cases. This is not so helpful if you are relying on the sitemap to be actually correct for that environment. For example, we are using the sitemap for pa11y tests. In our case, setting the default base url to prod is actually unhelpful because we need to test against the dev sitemap.

Workaround 2: Drush Cron

You can use your provider's cron interface to run drush cron and it will produce https links. In our case, we are hosted through Acquia and this hourly job produces https links:

/usr/local/bin/cron-wrapper.sh oursite.dev https://oursitedev.prod.acquia-sites.com &>> /shared/logs/default-drush-cron.log

πŸ› Bug report
Status

Closed: cannot reproduce

Version

4.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loopy1492

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @loopy1492
  • πŸ‡ΊπŸ‡ΈUnited States loopy1492
  • πŸ‡ΊπŸ‡ΈUnited States loopy1492
  • πŸ‡ΊπŸ‡ΈUnited States loopy1492

    Well, now I'm not so sure. I thought I'd done my due dilligence, but the environment I had been testing with suddenly stopped producing http links. So these environments had originally been set up to run cron hourly through the ui and also had a cron run set in the provider's back-end. I had tested the cron on one environment and found that it produced https links so I ruled that out. However, what I didn't take into account was that I'd modernized the cron task on that envirnment slightly, fixing some old syntax. I'd totally removed the cron from the environment I was testing the UI method on.

    Long story short is that I actually now think it was, perhaps, the incorrect cron method that may have caused this problem rather than setting the cron through Drupal UI. Since I've wiped out the old crons and they aren't saved anywhere, I can't really troubleshoot this. I guess the take-away for anyone who has this issue in the future and finds this post is to check your cron syntax.

  • Status changed to Closed: cannot reproduce almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States loopy1492
  • πŸ‡ΊπŸ‡ΈUnited States uri_frazier Portland, Oregon

    I'm experiencing http links being generated on an https multilingual site (with multiple domains). The issue was originally reported here:
    https://www.drupal.org/project/simple_sitemap/issues/2842097 β†’

    We also have reasons to not use the Default Base URL setting.

Production build 0.71.5 2024