perusio / drupal-with-nginx

Running Drupal using nginx: an idiosyncratically crafted bleeding edge configuration.
855 stars 246 forks source link

Drupal8: multi sitemaps 404 Not Found error #281

Closed Fahad-Alsaidi closed 6 years ago

Fahad-Alsaidi commented 6 years ago

I am using Drupal 8 and simple_sitemap to generate sitemap.xml. my site have more than 2000 nodes so simple_sitemap divided sitemap to sub-sitemaps like this: https://itwadi.com/sitemaps/1/sitemap.xml https://itwadi.com/sitemaps/2/sitemap.xml when I try to open one of these urls, I got 404 Not Found.

you can check here: https://itwadi.com/sitemap.xml

iryston commented 6 years ago

Try to change this location

## XML Sitemap support.
location = /sitemap.xml {
    try_files $uri @drupal-no-args;
}

to

## XML Sitemap support.
location ~ ^sitemap\.xml$ {
    try_files $uri @drupal-no-args;
}
Fahad-Alsaidi commented 6 years ago

@iryston I edit /etc/nginx/apps/drupal/drupal.conf but it doesn't work, now the main page of sitemap.xml doesn't work, check: https://itwadi.com/sitemap.xml

iryston commented 6 years ago

@Fahad-Alsaidi Sorry, that's my mistake.

You don't need to change location above. So, revert it back.

Just add this one to your config

location ^~ /sitemaps/ {
  location ~ ^/sitemaps/[[:digit:]]+/sitemap.xml$ {
    try_files $uri @drupal-no-args;
  }
}
Fahad-Alsaidi commented 6 years ago

Thanks @iryston, now it works.