1

Preconditions

app/etc/env.php

'directories' => [ 'document_root_is_pub' => true ],

'MAGE_MODE' => 'production',
  • document_root_is_pub is true
  • MAGE_MODE is have production value

sitemap.xml

  • Filename : sitemap.xml
  • Path : /media/

Admin => Stores => Configuration => General => Web:

  • Base Urls => Base URL for User Media Files =>{{unsecure_base_url}}media/

  • Base URLs (Secure) => Secure Base URL for User Media Files => {{secure_base_url}}media/



But while generating the sitemap.xml

Expected result

Actual result

NOTE : I have generated the sitemap from admin panel.

Any solution or advise will be really helpful.

  • 1
    Please set 'MAGE_MODE' to production in env.php file. 'MAGE_MODE' => 'production'. – Sunny Rahevar Aug 5 at 9:58
  • Hello @SunnyRahevar Thanks for your reply I have checked MAGE_MODE and it is already 'MAGE_MODE' => 'production', – Aditya Shah Aug 5 at 10:01
2

sometime problem happens when running the sitemap generation through bin/magento cron:run from outside of the magento directory.

  • e.g our magento code is in /var/www/src, if I run php src/bin/magento cron:run from /var/www the urls will contain src as part of the baseurl.
  • Running from the magento directory, e.g php bin/magento cron:run from /var/www/src, works as expected.
  • Running from ADMIN UI - Site generate will also works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.