How to Hide Rankmath sitemap from public

#360253
  • Resolved Eins Stark
    Rank Math free

    Hi, I wanted to know how to hide the Rankmath sitemap from Public view, but not search engines.

    For example, from usual “…./sitemap_index.xml” to something custom?

    Also how to hide sitemap URL from robots.txt file? Is it possible to create two robots.txt file?

    Could you provide me codes?

    Thanks!

Viewing 1 replies (of 1 total)
  • Prabhat
    Rank Math agency

    Hello,

    Thank you for contacting the support.

    We do not have an option to change the sitemap name but you can use a filter to change the base of the sitemaps. You can add the below filter to the website to change the sitemap base to /secretfolder/:

    /**
     * Filter to change the Sitemap URL Base
     *
     * @param string $base New URL Base
     */
    add_filter( 'rank_math/sitemap/base_url', function( $base ){
    	return "secretfolder/";
    }, 10, 1 );

    This would change the sitemap URL to ../secretfolder/sitemap_index.xml.

    Please follow this guide to add the filter:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    After adding the filter, please follow the below steps:
    1. Flush the Sitemap cache by following this video screencast:
    https://i.rankmath.com/pipRDp

    2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
    https://rankmath.com/kb/exclude-sitemaps-from-caching/

    3. Clear your website’s cache and browser’s cache.

    Once done, see if the sitemaps are moved to the desired location. Also, please ensure to remove all the sitemaps from your Google Search Console account and submit the new sitemap URL.

    You cannot “hide” the sitemap URL from robots.txt, you’ll have to remove it, which is not recommended as search engines bots access the sitemap URL from robots.txt.

    Also, the bots access the robots.txt under the location domain.com/robots.txt so creating multiple files would be of no help.

    Hope this helps clarify the situation.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘How to Hide Rankmath sitemap from public’ is closed to new replies.