1

I usually prefer the non-www URL for my website (http://example.com, not http://www.example.com). While submitting the site to Google one needs to set a preferred domain by choosing either the www or the non-www version of URL. Then, during submitting the sitemap, only the sitemap containing the preferred version of URL should be submitted to Google search console.

I have a website run by MediaWiki software. It uses a PHP script (named generateSitemap.php, it is bundled with the MediaWiki installation package) to create the sitemaps. One can set cron jobs to automate the process of updating sitemap at regular intervals.

The problem is my sitemap are being generated containing the www version of the webpages.

How should I instruct the programs to generate sitemaps without www in the URLs?

  • 1
    Does the $wgServer value (in LocalSettings.php) have the www? – unor May 6 '18 at 14:57
  • Maybe you could post-process the sitemap and use sed to remove the www. Add that to the same cron job. – Stephen Ostermiller May 7 '18 at 11:20
  • @unor, Yes, that was the problem. I corrected it and the sitemap is now producing non-www links. Thank you. Should I add an answer to this question? – Arnb May 8 '18 at 7:59
  • @Arnb: Great :) Sure, post an answer and accept it. – unor May 8 '18 at 14:35

Your Answer

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

Browse other questions tagged or ask your own question.