• Resolved thinkswan

    (@thinkswan)


    Hi! The WordPress 5.5 sitemaps return a 404 Not Found error on Nginx servers.

    To reproduce:
    1. Install WordPress 5.5 on any Nginx server
    2. Visit <your_site>/robots.txt to confirm the Sitemap: <your_site>/wp-sitemap.xml line is present
    3. Visit <your_site>/wp-sitemap.xml and notice it returns a 404 Not Found error

    This is because custom rewrite rules must be specified in your Nginx config. For the popular Google XML Sitemaps plugin, the required rewrite rules are:

    
    rewrite ^/robots\.txt$ "/index.php?robots=1" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
    

    What are the required rewrite rules to get WordPress 5.5 sitemaps working in Nginx?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Yui

    (@fierevere)

    永子

    You dont need any specific rules for sitemaps.

    Nginx

    Default configuration for permalinks will work fine.

    location / {
                    # This is cool because no php is touched for static content.
                    # include the "?$args" part so non-default permalinks doesn't break when using query string
                    try_files $uri $uri/ /index.php?$args;
            }
    Thread Starter thinkswan

    (@thinkswan)

    @fierevere Appreciate your help here. I have that location / {} directive in my Nginx config, but it doesn’t work for sitemaps.

    For example:

    robots.txt loads: https://www.stressatschool.com/robots.txt
    /sitemap.xml (from Google XML Sitemaps) loads: https://www.stressatschool.com/sitemap.xml
    /wp-sitemap.xml returns a 404 Not Found: https://www.stressatschool.com/wp-sitemap.xml

    Is there an equivalent /index.php?xml_sitemap=params=$2 link for built-in WordPress sitemaps?

    Moderator Yui

    (@fierevere)

    永子

    If your permalinks are working, you dont need to do anything else for nginx rewrites.

    If you are getting 404, then probably your wp-sitemap.xml sitemap is not generated.

    Check.

    If you have enabled visibility for search engines (Dashboard – Settings – General)
    If you have SimpleXML PHP extension
    If your SEO/Sitemap plugin did not disabled WP sitemap generation via filter.

    See

    New XML Sitemaps Functionality in WordPress 5.5

    • This reply was modified 3 years, 7 months ago by Yui.
    Thread Starter thinkswan

    (@thinkswan)

    Ah, you’re right! Deactivating the Google XML Sitemaps problem solved the problem.

    I removed that plugin and the custom rewrite rules and will rely on WordPress’s built-in sitemaps moving forward.

    Thank you for your help, I really appreciate it!

    Moderator Yui

    (@fierevere)

    永子

    WordPress native sitemaps are missing convenient settings,
    but you can tune them with filters, see the article linked above.

    I have the same problem.
    What can I do with this?
    I’v delete Google XML Sitemaps. I’m using PHP 7.4.9 with nginx and WP 5.5.1.
    Why retieve error 404?? https://snakeisland.com.ua/wp-sitemap.xml

    Thread Starter thinkswan

    (@thinkswan)

    @shehurin Sorry to hear you’re having trouble with your WordPress sitemaps. Can you try the following:

    1. Confirm the following is in your nginx config:

    
    location / {
      try_files $uri $uri/ /index.php?q=$uri&$args;
    }
    

    2. If you modified your nginx config, restart nginx: sudo service nginx restart
    3. Deactivate all other sitemap-related plugins (Google XML Sitemaps, Yoast, etc.)
    4. Confirm you have no posts or pages with a wp-sitemap.xml permalink

    After following those steps, does https://snakeisland.com.ua/wp-sitemap.xml work for you?

    1. Yes, sure.
    2. I have restarted nginx & php-fpm several times with testing configs (all success).
    3. I had Google XML Sitemaps before. But it has been deleted before I migrated to 5.5.
    4. Of Course, I have no pages with url wp-sitemap.xml.

    Now it not works. Moreover, it doesn’t work in several sites in my VPS. All sites is mine and nginx configs are the same.

    php7.4-xml, php7.4-mbstring, php7.4-zip – are installed

    Thread Starter thinkswan

    (@thinkswan)

    @shehurin I’m not sure then, sorry.

    Maybe @fierevere can help? 🤞

    Moderator Yui

    (@fierevere)

    永子

    @shehurin

    Please consider to open your own support topic.

    Please do not jump into other topics and detract from their problem. If the troubleshooting already posted made no difference for you, then, as per the Forum FAQ, please post your own topic. A lot more people will see your post, and that way you stand a good chance of getting the assistance you want. Despite any similarity in symptoms, your issue is likely to be completely different because of possible differences in physical servers, accounts, hosts, plugins, theme, configurations, etc. Thus one problem, on one setup is not indicative of the functionality and reliability of an application as a whole. Your post will be archived.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WordPress 5.5 sitemap does not load on Nginx server’ is closed to new replies.