sitemap.xml nginx problem

Events happening in the community are now at Drupal community events on www.drupal.org.
superfedya's picture

Hi,

After switching my site to Nginx my sitemap module stops working correctly:
http://madfanboy.com/sitemap.xml

Seems that this config doesn't work:

## XML Sitemap support.
location = /sitemap.xml {
    try_files $uri /index.php?q=$no_slash_uri;
}

Any suggestion?

Thanks

Comments

I thinks nginx doesn't works

superfedya's picture

I thinks nginx doesn't works correctly with the links like:
http://madfanboy.com/sitemap.xml?page=1
http://madfanboy.com/sitemap.xml?page=2
And always redirect them to http://madfanboy.com/sitemap.xml

I put everything on the 1 page and it works.

Does your map include

brianmercer's picture

Does your map include $args?

  map $uri&$args $no_slash_uri {
    default '';
    ~^/(?<key>.*)$ $key;
  }

EDIT: Yeah, that needs a fix: https://github.com/perusio/drupal-with-nginx/blob/master/map_drupal6.conf

No need to do that

perusio's picture

just use ;)

## XML Sitemap support.
location = /sitemap.xml {
    try_files $uri /index.php?q=$no_slash_uri&$args;
}

it will works even for:

superfedya's picture

it will works even for: sitemap.xml?page=1?

Yes

perusio's picture

by virtue of the $args that was as added.

FWIW, the following config

z.stolar's picture

FWIW, the following config worked for me, Drupal 7 on nginx:

location @xmlrewrite {
    # Some modules enforce no slash (/) at the end of the URL
    # Else this rewrite block wouldn't be needed (GlobalRedirect)
    rewrite ^/(.*)$ /index.php?q=$1;
  }
  ## XML Sitemap support.
  location = /sitemap.xml {
    try_files $uri @xmlrewrite;
  }
jcmartinez's picture

Hi,

I'm using D7 and the latest version of Perusio's configurations from github. I've chosen the basic Drupal seting: https://github.com/perusio/drupal-with-nginx/blob/D7/apps/drupal/drupal....

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

This does not work when the sitemap is large and gets split. I tried Perusio's suggestion with no luck:

location = /sitemap.xml {
    try_files $uri /index.php?q=$no_slash_uri&$args;
}

Nginx does not start because it doesn't know the variable $no_slash_uri.

I also used used z.stolar suggestion but it did not work.

Everything else is working.

Thank you in advance for helping.

That is for D6

perusio's picture

for D7 just do:

location = /sitemap.xml {
    try_files $uri @drupal;
}

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: