We’re sorry to hear you are experiencing this issue on your site.
We looked at the sitemap on your site and see that it isn’t loading from the standard URL of sitemap_index.xml and that URL is returning a 404 error, but that it is loading from the default WordPress permalink of ?sitemap=1.
Google Search Console is likely returning a status of ‘Couldn’t Fetch’ due to the value of the URL submitted being a query string.
A 404 error on your sitemap can be caused by a number of issues, including the permalinks or rewrite rules. As your sitemap is loading from the default WordPress permalink successfully, this would indicate that the issue likely due to the permalinks.
To resolve this, we would first recommend to try resetting the permalink structure in WordPress which can be done by performing the following steps:
• In WordPress, go to Settings>Permalinks
• Clicking ‘Save Changes’ without making any modifications
If you continue to receive the error after resetting the permalinks, we would then also suggest adding a set of rewrite rules to your server and we have a guide on adding these for an Apache servers here: https://yoast.com/help/xml-sitemaps-apache/ and for Nginx servers here: https://yoast.com/help/xml-sitemaps-nginx/.
We also have additional information regarding the sitemap files creating an error here: https://yoast.com/help/my-sitemap-is-giving-a-404-error-what-should-i-do/
After doing the permalinks settings I checked my website sitemap with the sitemap.xml URL and worked but it didn’t show the information in XML format it is some other format I guess HTML, is that an another issue?
Now I’ve changed the permalink should I continue adding rewrite rules in my apache server?
Thanks
Hi @nishankkawrat
Upon checking https://onlinebookpdf.xyz/sitemap_index.xml, we still see it loading as a 404. But the non-pretty permalink version of https://onlinebookpdf.xyz/?sitemap=1 is loading as expected.
Please do set up the rewrite rules. If you are using Apache, you can refer here. If you are using NGINX, you can refer here.
You didn’t set pretty permalinks in WP settings – https://wordpress.org/support/article/using-permalinks/ All pages use non-pretty permalinks (?page_id=nnn) and it’s bigger issue than sitemaps.
It doesn’t make sense to add rewrite rules in .htaccess right now. When you set pretty permalinks in WP (%postname%
) then sitemaps should work without additional rules.
If I change the permalink to postname all my posts and blogs will end up showing a 404 error. How can change it without getting a 404 error? Can you guide step-by-step?
It’s possible than your website uses nginx server or .htaccess isn’t writeable (if it’s apache server – https://wordpress.org/support/article/using-permalinks/#creating-and-editing-htaccess). You should contact your host for more details (about server type). Website is behind CF, so I can’t see “server signature”.
I have an Apache server and do you mean that I should add that code in my .htaccess file after changing my permalink settings to postname right?
WP automatically creates .htaccess, but it seems that there are something which is blocking this process. You can try to upload default .htaccess into root directory of your website (it’s often public_html) by instructions from previous URL. If it doesn’t work then please contact your host. It’s an issue related to WP core and your host, nothing directly related to Yoast.
We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.