How To Change Yoast Sitemap Url

If you utilize the Yoast SEO plugin for your WordPress site, you likely recognize the advantages of having a Sitemap. Sitemaps aid search engines in comprehending the organization of your site and navigating it more effectively. By default, Yoast generates a sitemap for your site. However, if you wish to modify the URL of your sitemap, follow these steps outlined in this post.

Understanding Yoast SEO Sitemap URL

The default URL for your Yoast SEO sitemap is usually your domain name followed by ‘/sitemap_index.xml’. For instance, if your website is ‘www.example.com’, your sitemap URL would be ‘www.example.com/sitemap_index.xml’.

Steps to Change Yoast Sitemap URL

It’s important to note that Yoast SEO does not directly allow you to change your sitemap URL. But, don’t worry. There’s a workaround via the .htaccess file. You need to have access to the file system of your WordPress installation, or use a plugin that allows you to edit the .htaccess file.

Step 1: Access .htaccess file

The .htaccess file is located in the root directory of your WordPress installation. If you are accessing via FTP, it’s typically in the ‘public_html’ or the ‘www’ folder.

Step 2: Add RewriteRule

Now, you will need to add a RewriteRule to the .htaccess file. This rule basically redirects requests from your old sitemap URL to the new one. Let’s say, you want to change your sitemap URL from ‘www.example.com/sitemap_index.xml’ to ‘www.example.com/newsitemap.xml’. You will need to add the following rule to your .htaccess file:

    <br>
    RewriteRule ^sitemap_index\.xml$ /newsitemap.xml [R=301,L]
    <br>
    

The R=301 is a permanent redirect, and the L means this is the last rule to be processed if the condition is met.

Step 3: Save and Check

After adding the RewriteRule, save the .htaccess file. Now, if you try to access ‘www.example.com/sitemap_index.xml’, you should be automatically redirected to ‘www.example.com/newsitemap.xml’.

Summary

Changing the Yoast Sitemap URL involves tweaking the .htaccess file. Always remember to backup your .htaccess file before making any changes to it. If things go wrong, you can always revert to the backup file. Hopefully, this blog post has clarified the process for you. If you have any questions or need further assistance, feel free to ask in the comments section below. Happy SEO optimizing!