I am using magento 2.4.1 and currently set in production mode with changes to doc root pointing to pub folder as per doc. I can create sitemap.xml in pub folder but online validators can not find the sitemap with error 404 showing in response header . I have searched the net for past few days and yet I have not been able to find a solution.
Setup: Linux Ubuntu server Magento 2.4.1 Apache2 webserver . Any info would be greatly appreciate.
CodePudding user response:
Regardless of the path you may specify, you will get the following error all the time:
Path "mypath/mysitemap.xml" is not available and cannot be used. As you can imagine the problem is not very clear as the error is misleading to a different source.
The only way to avoid the problem, without touching core files that are, is to understand that Magento wants a specific name for the sitemap, and it will not accept anything else:
sitemap.xml
However, to have more sitemap.xml, one for each store view, you will need to manage sub-paths, like:
myrootfolder/sitemaps/mystoreview_[1,2,3...,n]/sitemap.xml
If you would like a clean approach you can, however, work with the rewrites to let the Apache serve a clean URL for the sitemap:
RewriteCond %{HTTP_HOST} ^.*yourstore_1.com$ RewriteRule ^sitemap.xml$ yourpath/sitemap.xml [NC]
CodePudding user response:
Problem seems to be solved. I have my site set to production. Vhost Directory set to pub. I modified env.php to serve content from pub., but the issue was env.php was never saved correctly. Now, I have access xml. and validator can find and validate the xml page.
