Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix XML sitemaps to work by forcing .htaccess to pick them up. Add this to the .htaccess, above the WordPress rewrites. This version assumes you're using a subfolder install with WordPress installed in /wordpress/, adapt if needed.
# WordPress SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^sitemap_index.xml$ /wordpress/index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix
@lawrencetaur

This comment has been minimized.

Copy link

commented Sep 17, 2013

whats the nginx alternative for this.

your plugin generates
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

but that doesnt work, i get 404s. my sub directory is domain.com/blog/

@benarent

This comment has been minimized.

Copy link

commented Oct 22, 2013

I also have an install of nginx that forces closing /

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# WordPress SEO - XML Sitemap Rewrite Fix
RewriteRule ^sitemap_index.xml$ /wordpress/index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix
</IfModule>

http://nblog.airbrake.io.php53-5.ord1-1.websitetestlink.com/wp-admin/admin.php?page=wpseo_xml
http://airbrake.io/blog/sitemap_index.xml/

@ex-jedi

This comment has been minimized.

Copy link

commented Sep 18, 2014

Yep, seems to work fine. Thanks for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.