Bit of random redirect issue with the 8.x-1.0-alpha-5, when exit testing alongside simple_sitemap 8.x-2.8 and 8.x-2.9, the sitemap.xml was not served due to redirect loop.
/sitemap.xml?q=sitemap.xml?q=sitemap....
Might be a carry-over from similar issue in 8.x-1.0-alpha-4 ?

Comments

hughmccracken created an issue. See original summary.

berdir’s picture

Please read the last few comments in #2852680: Redirect loop when serving cached pages to anonymous users, most like a misconfiguration on your side, happy to add a workaround but I can't reproduce so can't really fix. Probably at some point we want to force-remove the ?q query parameter.

ressa’s picture

The Redirect 8.x-1.0-alpha-5 module works as expected for me with simple_sitemap 8.x-2.7+5-dev, without redirect loop.

joos’s picture

Had a similar problem today after upgrade to 8.3. The site kept looping to q=/?q=/?q=/...

The problem for me was the setting "Enforce clean and canonical URLs." which I disabled to get it to work. Could very well be a config error in my nginx.conf but Ive not been able to find a solution there. A functional example config for nginx would be nice?

replicaobscura’s picture

It's a config error in nginx.conf I think (or possibly other server software if you aren't using nginx), check out my last comments in the issue Berdir linked to regarding what the actual issue is, however that alone might not fix it for sitemap.xml.

Pantheon's current nginx config seems to be broken. It does what I did in the comments there to fix it for normal URLs, but Pantheon still sends certain other URLs, such as sitemap.xml, through @cleanurl which uses the ?q= query string parameter. I've opened a ticket with them to ask about it.

Not sure if you're on Pantheon, but likely you've got the same nginx config issue they currently do.

joos’s picture

Yes, config update fixed our issue. Nginx has a page for Drupal now.
https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/

evanjenkins’s picture

bmcclure did Pantheon ever get back to you on this issue?

replicaobscura’s picture

Ticket is still open, I provided detailed information and reproduction steps and they said they're looking into it currently.

replicaobscura’s picture

If anyone's running into this and needs a stopgap solution until it can be resolved in their hosting environment, I put this quick module together:

https://github.com/bmcclure/drupal-sitemap_nginx_config_fix

It simply disables the canonical link redirect behavior on the sitemap.xml path. For me it resolves the issue on Pantheon, until they get the config updated.

If you don't want to enable a whole new module, they key is just to detect the sitemap path and call: \Drupal::request()->attributes->set('_disable_route_normalizer', TRUE);

evanjenkins’s picture

Awesome thanks! If you wouldn't mind updating when/if they give you an answer I'd appreciate it. Hitting my head on this.

johnhanley’s picture

Any update on the Pantheon ticket? What's the recommended configuration to resolve this?

I recently ran into this issue after an upgrade to 8.x-1.0-alpha5. I have a Pantheon hosted D8 application that's failing to serve sitemap.xml due to "redirected you too many times."

The aforementioned workaround module fixes the problem (thanks bmcclure), but a permanent solution is optimum.

Please advise.

replicaobscura’s picture

No new update from Pantheon yet--I sent them a request for current status today to see if they're working on it.

In the meantime, this small module can fix the issue: https://github.com/bmcclure/drupal-sitemap_nginx_config_fix

karens’s picture

I ran into this as well. Not only does this happen at sitemap.xml, it also happens at rss.xml. And probably other non-standard urls.

The module referred to fixed sitemap.xml but rss.xml is still broken. The module could be updated to fix that as well, but there is no telling what other urls might be impacted that haven't been discovered yet.

Instead I looked at the other Redirect settings to see if any of them could fix this. I finally found that unchecking "Enforce clean and canonical URLs." takes care of all the problems I ran into.

I think the code that implements that must be a little too aggressive, at any rate that fixes my problems and all my redirects still work as they should with it unchecked.

replicaobscura’s picture

@KarenS: You're right about that setting being the problem--the module I created disables that setting for certain paths only, to allow for all other paths to still require canonical URLs. Other than that, the fix is the same as simply disabling that option.

Still no updates from Pantheon on a fix for this btw.

johnhanley’s picture

Just a word of warning. The temporary fix module in this thread breaks geolocation. As a result we had to disable it and wait for a proper solution from Pantheon.

replicaobscura’s picture

@johnhanley: Do you know what about it breaks geolocation? Its only function is to call one method in redirect's settings that disables the canonical URL redirect on the /sitemap.xml URL, so it doesn't seem like it should have any interaction with geolocation at all.

roam2345’s picture

the same happens for rss.xml its also gets stuck in this loop.

replicaobscura’s picture

Great news! Latest reply from Pantheon:

Our engineering team has deployed a fix for this and the issue should now be resolved.

I haven't tried it without the fix yet, but here's hoping it's all working properly now!

johnhanley’s picture

@bmcclure: sorry for the delayed response. I now can't remember the particulars, but enabling the module cause some weird anomalies so we quickly disabled it. It's probable our issue was completely unrelated.

roam2345’s picture

Can happily report this has been solved as well for us with pantheon.

berdir’s picture

Category: Bug report » Support request
Status: Active » Fixed

Great, then lets close this :)

Changing to a resolved support request seems to make the most sense.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.