Sitemap is essential for any website and WordPress blogs aren’t any different. There are lots of plugins for WordPress that automatically generate sitemap.xml files according to custom set rules. But Google XML Sitemaps is the most widely used plugins for sitemap generation in WordPress for its plethora of options for customizing the sitemap. But, if you have set the www version as the default canonical URL and have redirected the non-www version to the prior, you’ll get an error saying that the sitemap’s stylesheet is missing. Same is the case if you set non-www as default and redirect the www version to the prior. The sitemap thus won’t load. This can cause a problem while submitting sitemaps to Webmasters or other places if you don’t use the default canonical URL form. Well here is the fix.
Let us assume that you use non-www version as the default URL. When you open the URL for the sitemap.xml file with the www version, you’ll get an error saying:
Error loading stylesheet: An unknown error has occurred (805303f4)
This stylesheet error can be fixed by modifying your .htaccess file. You just need to add the following line to your .htaccess file. Replace ‘domain.com’ with your domain.
[code]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
[/code]
Now if your canonical URL is the www version by default, use the following code.
[code]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
[/code]
Thus, you can easily fix sitemap.xml redirection issue caused due to stylesheet error.