Preconditions
app/etc/env.php
'directories' => [ 'document_root_is_pub' => true ],
'MAGE_MODE' => 'production',
document_root_is_pub
istrue
MAGE_MODE
is haveproduction
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 via cron
Expected result
sitemap.xml
index urls to sitemap should be https://magento-site/media/sitemap-1-1.xml
Actual result
sitemap.xml
urls look like https://magento-site/pub/media/sitemap-1-1.xml
NOTE : When sitemap is generated from
admin
panelsitemap
contains the proper urls, But somehow withcron
it comes wrong url (containspub
in the url)
Most likely reason (Might be) But not in my case
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. - But my cron is generating from
/var/www/src
- And Running from ADMIN UI - Site generate will also works as expected.
Any solution or advise will be really helpful.