1

is there an easy way to rewrite our sitemap to Magento sitemap directory?

So:

  • example.com/sitemap.xml
  • www.example.com/sitemap.xml
  • anotherexample.com/sitemap.xml
  • www.anotherexample.com/sitemap.xml

get redirected to

  • example.com/sitemaps/example.com/sitemap.xml

  • example.com/sitemaps/example.com/sitemap.xml

  • anotherexample.com/sitemaps/anotherexample.com/sitemap.xml

  • anotherexample.com/sitemaps/anotherexample.com/sitemap.xml

I was looking at this, but just not the same: multi store view sitemap.xml url rewrite

Many thanks

2 Answers 2

1

When generating the sitemap you can fill in the folder where it should be created. Just create the folder structure you need and fill in the path field with it.

0

Using Nginx we succeeded in doing just that using

location ~* /sitemap\.xml$ {
    rewrite ^(/..)?/sitemap.xml$ $1/sitemaps/$storecode/sitemap.xml permane$
}

What is does is: filter for sitemap.xml rewrite to folder /sitemaps/{MAGE_RUN_CODE}/sitemap.xml Works perfectly As long as your {MAGE_RUN_CODE} detection is flawless

The added (/..)? adds support for example.com/en and example.com/fr language sites and should be adjusted when creating other subdirectories

Good luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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