We run a travel blog (joyofexploringtheworld.com) on a budget VPS with Docker Compose, Cloudflare, and Traefik. When we added Rank Math for SEO, the sitemap worked in the admin but returned 404 on the public URL. Here’s what was going on and how we fixed it.

The problem Link to heading

Rank Math generates sitemaps at runtime via index.php?sitemap=1. On Apache or Nginx with .htaccess/rewrite rules, the pretty URL /sitemap_index.xml gets routed to WordPress automatically. With Traefik, that routing doesn’t exist by default—Traefik doesn’t use .htaccess, so /sitemap_index.xml never reaches WordPress and you get a 404.

How to fix it Link to heading

1. Isolate the issue Link to heading

Test both URLs:

  • https://yoursite.com?sitemap=1 — if this works, WordPress is fine; the issue is routing
  • https://yoursite.com/sitemap_index.xml — if this 404s, Traefik isn’t sending the request to WordPress

2. Add Traefik path routing Link to heading

Configure Traefik so /sitemap_index.xml and *-sitemap*.xml are routed to WordPress. Add a path prefix rule or middleware that forwards these requests to your WordPress backend. The exact config depends on your setup (Docker labels, file provider, etc.), but the goal is that any request for a sitemap path hits WordPress instead of returning 404.

# Traefik static config — single-file provider
command:
  - '--providers.file.filename=/etc/traefik/dynamic/real-ip.yaml'
  # NOT --providers.file.directory — only this file is loaded

If Traefik uses --providers.file.filename (not directory), only that one file is loaded. WordPress rewrite rules rely on all requests hitting index.php, so Traefik must route /sitemap_index.xml to the WordPress backend.

In WordPress: Settings → Permalinks → Save (no need to change anything). This refreshes rewrite rules and can resolve stale routing.

4. Exclude sitemap from caching Link to heading

If Cloudflare or a caching plugin caches the sitemap, search engines may see stale or empty content. Add a cache bypass rule for /sitemap*.xml or /sitemap_index.xml.

5. Remove conflicting static files Link to heading

If you have a physical file named sitemap_index.xml in your web root, it can shadow Rank Math’s virtual sitemap. Remove or rename it.

What you can do Link to heading

Virtual sitemaps need server rewrites; Traefik requires explicit config, unlike Apache’s mod_rewrite. Once routing is correct, Rank Math’s sitemap will work as expected.

The Traefik config is in the companion repo.

See also: Running a WordPress Travel Blog on a Budget VPS: The Full Stack | Why Our Site Went Down for an Hour


Built for a travel blog on a budget. This stack powers Joy of Exploring the World — curated travel itineraries, restaurant reviews, and destination guides. If you're planning your next trip, come explore with us.

All config files from this post are in the companion GitHub repo.