Since you are using Nginx as your web-server, please configure the following rewrite rules in case you get 404 Not Found errors for your sitemap:

Just installed Google XML Sitemaps into the Bedrock site via composer:

"require": { "php": ">=5.5", "etc etc": "..." "wpackagist-plugin/google-sitemap-generator": "4.0.8" }

Plugin displayed this message:

"Since you are using Nginx as your web-server, please configure the
following rewrite rules in case you get 404 Not Found errors for your
sitemap:

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;

Followed Scott’s documentation to do so, and created a file with the following content:

server {
  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;
}

It’s named rewrites.conf.j2 and resides at:

trellis/roles/wordpress-setup/templates/includes.d/delapiedralawfirm.com/rewrites.conf.j2.

Deployed and now blablabla.com/sitemap.xml is resolving.

Thought it might help someone.

6 Likes

Bump.

  1. The above location for the .conf.j2 file is outdated, as noted in the documentation.
  2. Remove the server { and } from the above code, it’s no longer required either.

And a problem, in the documentation…

Tip: Append --tags nginx-includes to your command to run only the relevant portion of the playbook.

…no longer appears to work? I tried running this and it didn’t even create the new directory on the server.

And even after getting this working, I made a small change to the file, tried the playbook with tags and it didn’t update the file.

A full playbook run did the trick.

1 Like

Some people reporting ineffective --tags nginx-includes find that they haven’t yet applied this January 29, 2017 update to Trellis: http://github.com/roots/trellis/commit/346d97e

Those wanting to postpone this update could try the slightly less targeted --tags wordpress

1 Like

That’d make sense. I started this project in December '16. Thanks.

1 Like