How do you configure the Simple Sitemaps for Multisite with Nginx

Just as the title suggests, my web server runs on Nginx. I'd like to install this plugin, but to have it setup properly across my network, I need to make sure the rewrite rules are inserted correctly.

Server rules are not my specialty, so I just want to be careful. Please let me know if you need any additional information.


  • will_brooke8
    • WPMU DEV Initiate


    JBSV1 noted clearly that he is running NginX (I am too).
    I have not attempted to use the sitemaps plugin yet (its on my list) but I can assure that the above instructions will NOT work with NginX without some modification.

    Because NginX does NOT use Apache directives in .htaccess files...

    The relevant line in the documentation:
    RewriteRule ^(.*/)?sitemap.xml wp-content/sitemap.php [L]

    needs to be changed to:

    rewrite ^/(.*)?sitemap.xml /wp-content/sitemap.php last;

    (the entire .htaccess file would need to be re-written... use the googles, or check out this tool: )

    ALSO NOTE: this assumes you have the rewrite module ( in your NginX install!

  • Timothy Bowers
    • Chief Pigeon

    Hey there.

    I don't use nginx, there are tons of different types of setups and I simply don't know them all.

    Interesting to know though so I just went and did a little research (amongst many articles):

    I quiet like this tool here:

    Could be rather handy, it tells me

    RewriteRule ^(.*/)?sitemap.xml wp-content/sitemap.php [L]

    Should be:

    location / {
      rewrite ^/(.*/)?sitemap.xml /wp-content/sitemap.php break;

    Thanks for the insight.

  • jbsv1
    • Site Builder, Child of Zeus

    Timothy, Will,

    Thank you both for your help. Together you two have given me new resources to bookmark and use and later reference.

    I added "rewrite ^/(.*)?sitemap.xml /wp-content/sitemap.php last;" to my webserver .conf file among the other lines related to files for my blogs. It's not nested within a "location," but it seems to work okay.

    I didn't want to add the rewrite to my existing "location / {" directive simply because I preferred to keep it together with other rewrites of its kind. So I haven't tried it.

    To summarize:

    I installed the plugin, and moved the sitemaps.php file as instructed within the usage page.
    Then I added " rewrite ^/(.*)?sitemap.xml /wp-content/sitemap.php last; " to my webserver's .conf file located with the "/etc/nginx/sites-available" folder.
    Next I had the server reload the .conf with the following command "nginx -t && service nginx reload" to make sure it detected my changes.
    For testing I visited one of my subdomains at

    Looks good.

    Thanks again!

  • will_brooke8
    • WPMU DEV Initiate


    you are correct that the rewrite rules in a .htaccess dont necessarily benefit from or require a location declaration, as the .htaccess parent directory should act as its own location declaration (this may be incorrect, but is how i understand it... caveat administrator). I mentioned the location declaration in reference to the server declaration in the site configuration (/etc/nginx/sites-enabled/yoursite.conf ) as I personally prefer to avoid .htaccess files...

    You CAN certainly use a location declaration in your .htaccess as Tim describes, but, as you found, it isn't necessary!

    Check out ; some really detailed and helpful configuration walkthroughs. I am currently using a modified version of one of the setups from there.


    While I can appreciate that there is an uncountable number of server stack configurations, I would simply state that NginX is making converts of MANY of us old Apache warhorses. It strikes me that producing Apache specific code or documentation limits your audience unnecessarily. To start, a simple note in the documentation that "the following configuration/.htaccess file applies to Apache based configurations... " and as the community generates tested replacements, it would be nice to provide alternative resources for us NginX users.

    I am trying not to be evangelical, but WP runs very nicely on NginX; I am currently running a dozen small sites using just 128Mb of ram with NginX behind Varnish + some opcode caching. Dont try that with Apache, it will devour 128Mb for a single worker thread!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.