• Resolved danniee

    (@danniee)


    Hi,

    I’ve been looking for a way to change the sitemap url because this is absolutely essential to me for various security reasons. I know doing so won’t stop everyone who wants to find it, but probably the majority.

    Either way, I have tried to get help from you guys but it seems you are a bit reluctant to even point me in the right direction.

    Did some research and found out the url can be changed by doing edits in the class-sitemaps-router.php file. I did so and the url did indeed change. My question is, by doing that will the sitemap still ping the search engines correctly when edits are made? I assume if I just point to the right url in Google Search Console, Google won’t have any issues finding the sitemap?

    I hope you can help me with this because I’ve been trying to find a solution for months :/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hi @danniee,

    You mentioned that you’ve managed to change the URL of your sitemap(s) by editing a core file of the plugin and that actually worked for you. Can you please illustrate to us an example or show us how sitemaps URL now looks like vs what it was before? We asked because we’d like to be more clear on your requirement and the change in order to be able to suggest you further.

    Thread Starter danniee

    (@danniee)

    Hi @suascat_wp

    Thank you for helping!

    All I really did was to edit this line on row 34

    add_rewrite_rule( 'sitemap_index\.xml$', 'index.php?sitemap=1', 'top' );

    I just changed sitemap_index to something randomly like sitemap1_index and it worked. /sitemap_index gives 404 but /sitemap1_index directs to the sitemap.

    I’m not a programmer and don’t really know what I’m doing so that’s why I’m asking if something as simple as that solves my problem?

    Hi @danniee,

    We can understand that it’s a bit frustrating since there isn’t an easy way to change the URL of the sitemap index. As you’re aware, the sitemap can always be accessed using /?sitemap=1 on any domain using Yoast SEO.

    You can change that line you mentioned, but we don’t recommend changing the code in the plugin itself since all your changes will be lost each time the plugin updates. As an alternative, you or a developer can use the WordPress Rewrite hooks using a separate code snippets plugin or the functions.php in a child theme.

    Since sitemap_index.xml appears in multiple places in the code, changing the URL would mean that the following features may no longer work: redirects from sitemap.xml and the WordPress core sitemap to the Yoast sitemap index, caching the sitemap index, and the feature that pings Google and Bing.

    Hope this information helps.

    Thread Starter danniee

    (@danniee)

    Hi @priscillamc

    Thank you for the help. Does this mean that it’s possible as long as I use the method suggested, or that it likely won’t work and might break the ping function and other things too?

    Plugin Support devnihil

    (@devnihil)

    @danniee Modifying the class-sitemaps-router.php file in the way you described is not recommend, and may break other sitemap functionality. In addition, since the modification is to one of the plugin’s core files, it can also be overwritten during a plugin update.

    Thread Starter danniee

    (@danniee)

    @devnihil

    Yes, but isn’t that what child themes are for? I’m sure it must be possible though? Google doesn’t require a sitemap to be located at /sitemap.xml or whatever, right? But if not, the only option left for me is to turn off the sitemap functionality and submit posts and pages manually or find another approach.

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    If you have overridden the sitemap functionality from the child theme, it’s fine. But, if you have modified the Yoast SEO plugin files, it’s not a recommended way to do so as once you update the plugin, all the customization you have so far will disappear.

    On the other hand, you are right that Google doesn’t need the sitemap URL to be sitemap.xml. You can use whatever you wish to do so.

    Thread Starter danniee

    (@danniee)

    Thank you for your reply. Does this mean that editing that one line I posted here and add it to the child theme will be enough to accomplish what I want, or do I need to use rewrite hooks as suggested to change all instaces of sitemap_index.xml in the code?

    Hi @danniee,

    Using the rewrite hooks will change the sitemap URL as a workaround, but it will not fix the other features like pinging search engines, unfortunately.

    We hesitate to recommend anything like changing the code in multiple places in the plugin to update the URL since that may break your site at some point and we’re not able to offer support for custom code.

    That said, here are some options that might work for you:

    1. There isn’t an easy fix, so we recommend creating a feature request to be able to change the sitemap URL. This will bring this to the attention of our developers so that they can review it and decide whether this feature is something that can be added in a future release.

    2. If you’d like to implement this feature or change the code yourself in the plugin, we recommend contacting a developer who can look at your site and give you more specific guidance. Just keep in mind that any custom code may need to be tested or updated whenever there are plugin updates.

    Thread Starter danniee

    (@danniee)

    @priscillamc thank you for your kind help.

    Does your company offer customization services or do you mean I should turn to other developers for help?

    Plugin Support devnihil

    (@devnihil)

    @danniee We’re sorry, but we do not currently offer any types of customization or custom development services.

    On the Yoast Partners page you will find a list of companies we trust, and a description of the kind of projects these companies can take on: https://yoast.com/yoast-partners/

    Thread Starter danniee

    (@danniee)

    It’s unfortunate doing something as “simple” as changing a URL proves to be so hard. I think the best solution for me is to deactivate the sitemap and find another approach.

    Plugin Support devnihil

    (@devnihil)

    @danniee We’re sorry that this something that is easily accomplished. Also, if you are trying to prevent other users other than the main search engine bots from accessing the sitemap, you might want to look into setting up some security rules to prevent unwanted access to it. Your hosting provider may be able to assist you with that or offer some direction on how to best implement.

    Thread Starter danniee

    (@danniee)

    Ok, good advice! Will look into it thanks.

    Thread Starter danniee

    (@danniee)

    I’ve just found out “All in One SEO Pack” allows you to change the path since they use filter hook. Is this not something Yoast can implement too so I won’t have to migrate to that plugin? Yes, I can request such feature but if it’s going to take months to get it done then I have to abandon Yoast :/

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Change sitemap url’ is closed to new replies.