A
A
astaxov812020-06-16 21:50:49
WordPress
astaxov81, 2020-06-16 21:50:49

How to set up a redirect from sitemap_index.xml to sitemap.xml (wordpress/yoast seo)?

Hello.

Please tell me how to solve the problem. Now the redirect from sitemap_index.xml to sitemap.xml does not work on the hosting. The sitemap is generated using yoast seo. Here is the original data:

  • Hosting: timeweb
  • WP version: 5.4.2
  • Yoast SEO version: 14.3


The sitemap is only available at site.com/sitemap_index.xml. Is there a fix? (htaccess or add something to functons.php)? I would be grateful for help.

UPD: found this fix:
# BEGIN XML Sitemaps
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ /sitemap_index.xml [R,L]
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 [L]
</IfModule>
# END XML Sitemaps


How correct is it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Dmitriev, 2020-06-18
@astaxov81

Why don't you like site.com/sitemap_index.xml? This sitemap is easily processed by search engines. I wouldn't do anything for a redirect.

M
mipfikus, 2020-06-16
@mipfikus

Better, I think, just make another sitemap with the name sitemap.xml, and disable the sitemap from yoast, there is a lot of superfluous in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question