Multi Domain Feed Redirect not working

Hi guys,

I have a blog under two domains (.com and .de). They are in different folders /de and /en and handled through redirects.

I just noticed that that does not seem to work for my feed.xml file however. I get the same feed.xml for english and german and its seemingly random after each build which one I get.

So if I call saufwein or saufwein I always get the same but random feed either for both in german or for both in english and I have no idea why

Here are my redirect rules:

[[redirects]]
  from = "https://stoic-davinci-059d67.netlify.com/de/*"
  to   = "https://www.saufwein.de/:splat"
  status = 301
  force = true  

[[redirects]]
  from = "https://stoic-davinci-059d67.netlify.com/en/*"
  to   = "https://www.saufwein.com/:splat"
  status = 301
  force = true  

[[redirects]]
  from = "https://stoic-davinci-059d67.netlify.com/*"
  to   = "https://www.saufwein.de/:splat"
  status = 301
  force = true  

[[redirects]]
  from = "https://saufwein.com/*"
  to   = "https://www.saufwein.com/:splat"
  status = 301
  force = true  

[[redirects]]
  from = "https://www.saufwein.de/feed"
  to   = "/de/feed.xml"
  status = 200
  force = true  

[[redirects]]
  from = "https://www.saufwein.com/feed"
  to   = "/en/feed.xml"
  status = 200
  force = true  

[[redirects]]
  from = "https://www.saufwein.de/*"
  to   = "/de/:splat"
  status = 200
  force = true  

[[redirects]]
  from = "https://www.saufwein.com/*"
  to   = "/en/:splat"
  status = 200
  force = true

@tobi Welcome to the Netlify community.

I’m not a redirect expert, but I for the first two redirects I would just use /de/ and /en/ instead of the full domain name, especially in this case where you are using the Netlify subdomain as the redirect source.

I don’t understand the third redirect. You seem to be trying to redirect all traffic from the Netlify subdomain to your .de domain. Can that be correct?

The final redirect is unneeded because you can set your .com domain as the primary and this will happen automatically. At any rate, there is a conflict between the third and fourth redirects.

Which custom domain do you have set as the primary in your Netlify dashboard?

Finally, have you checked this section of the documentation?

The .de domain is the primary domain.
There are more than four redirect rules. It just puts them in a scrolling thing.

I try to explain my thoughts behind the rules:

[[redirects]]
  from = "https://stoic-davinci-059d67.netlify.com/de/*"
  to   = "https://www.saufwein.de/:splat"
  status = 301
  force = true  

[[redirects]]
  from = "https://stoic-davinci-059d67.netlify.com/en/*"
  to   = "https://www.saufwein.com/:splat"
  status = 301
  force = true  

[[redirects]]
  from = "https://stoic-davinci-059d67.netlify.com/*"
  to   = "https://www.saufwein.de/:splat"
  status = 301
  force = true 

Redirect netlify subdomain traffic. If it goes to /en or /de directly to the respective subdomains and if it goes somewhere else then by default to .de. This should catch everything not caught by the first two rules.

[[redirects]]
  from = "https://saufwein.com/*"
  to   = "https://www.saufwein.com/:splat"
  status = 301
  force = true 

Since .de is my default domain this does the redirecting for .com without www.

[[redirects]]
  from = "https://www.saufwein.de/feed"
  to   = "/de/feed.xml"
  status = 200
  force = true  

[[redirects]]
  from = "https://www.saufwein.com/feed"
  to   = "/en/feed.xml"
  status = 200
  force = true  

Redirect /feed to respective feed.xml. This is one of the things not working. They both seem to go to the same feed.xml and I don’t understand why.

[[redirects]]
  from = "https://www.saufwein.de/*"
  to   = "/de/:splat"
  status = 200
  force = true  

[[redirects]]
  from = "https://www.saufwein.com/*"
  to   = "/en/:splat"
  status = 200
  force = true

Redirect and rewrite all other traffic going to .com or .de to the respective subfolders with the english or german page at /en or /de. As I understand it this should route .de/feed.xml to /de/feed.xml and .com respectively but it does not either. They both go to the same feed.xml.

I tried changing the first three rules to the directories instead of the domain.
Then I don’t get the redirect to the domain anymore and it changes nothing regarding the feed problem.

I even get different feed.xml files for /feed and /feed.xml but always the same for /feed for .com and .de and the same for /feed.xml for .com and .de

To clarify my problem a screenshot:

This is /feed.xml for .com which is the wrong feed because it is the german one. If I put .de there then I get the correct german feed. So same file for .de and .com.
Same happens with /feed but there it is not the english but the german feed showing

One more observation: It seems to change after each deploy randomly. Now all 4 ways to access (.de/feed, .com/feed, .de/feed.xml and .com/feed.xml) lead to the german file which is located at /de/feed.xml

It’s also broken without the /feed rewrite rules.

Since this worked a few weeks ago something seems to be wrong with handling redirects and xml files. All other files seem to work fine with the redirect rules and switching between german and english works for all other pages I tested. Just the feed.xml is messed up

@tobi This may be a stupid question, but why not just have two separate sites, one for each language?

That’s not a stupid question at all. It’s easier to manage it in one place since everything in Hugo is set up that it just works now. The cross-links set by hugo work great when it is all managed in one place, since it just magically places the correct links for translations and stuff. Also media only needs to be processed once. Being able to have cross-language links in the already translated parts of the page appear and to have them not appear when its not translated yet without any manual work is great.

Thats why I’d like someone of the netlify team to take a look since it did work a while ago. I think it worked until this morning actually. I got english articles in my german newsfeed today. That’s why I noticed. Maybe it’s something wrong on some CDN Nodes or a bug in rewriting. It is just this one file that is getting mixed up. I am very certain that I checked when I set up the english feed a few months ago that the rewrites worked correctly and since I never got english articles in my german newsfeed it must have worked until today.

A possibility is that you’re using subdomain.netlify.com while last year it changed to subdomain.netlify.app. Maybe changing that might help? I see you say it worked till recently, so I’m not very sure.

Thanks for the suggestion but I don’t think that’s it. The redirect rules from the netlify domain have no impact on the bug. If I remove them I still have the problem. The error is connected to the last two redirect rules:

The issue is in redirecting .de/* to /de/:splat and .com/* to /en/:splat where I get rewritten/redirected to the same /de/feed.xml right now for both .de and .com domains.

And since that worked fine until yesterday and since it is still working fine for seemingly all other files excep the feed.xml files, I recon it’s a bug.

If I download the deploy everything looks fine. So there is a german feed xml in /de/ and an english feed xml in /en/

I just checked, your URL https://www.saufwein.de/feed, returns a 404, so it’s probably that’s why. Maybe you can add an index.html at the URL /feed/ and then it works?

Also, you can try using 301 instead of 200 for those too.

Lastly, if none of that works, you can create an index.html like I mentioned in the first point and add a redirect in that file like this: <meta http-equiv = "refresh" content = "0; url = http://example.com/"/>

I removed the /feed redirects. That’s why you get a 404.

The two rules in place now are these:

[[redirects]]
  from = "https://www.saufwein.de/*"
  to   = "/de/:splat"
  status = 200
  force = true  

[[redirects]]
  from = "https://www.saufwein.com/*"
  to   = "/en/:splat"
  status = 200
  force = true  

And there is a feed.xml in the /de/ folder as well as the /en/ folder.

The /feed with direct rewrite to the file was just a test.
The setup that worked until yesterday was the one I have set up now.

So redirecting all .com url calls to /en/:splat and all .de calls to /de/:splat

That’s what I would like to keep as well since feed readers etc are pointed to .com/feed.xml and .de/feed.xml right now.

If I change that to 301 then it would redirect to .com/en/feed.xml, right? That’s what I’d like to avoid

Oh and I just noticed that it seems to have changed languages again. While both .com/feed.xml and .de/feed.xml yesterday lead to the german file they both now lead to the english feed. And I recon when I redeploy then that changes again.
It has to be some bug, right?

Just tried that: Simply redeploy the same state as I deployed yesterday evening. And yes, now both are german again.

To clarify what I think should happen: I go to .de/feed.xml, then the first rule that matches is the one that should rewrite that to /de/feed.xml. And the .com to the /en/feed.xml. But what happens is that somehow both rules rewrite to the same file. And only for this one file. The same rule works fine for the index and all other pages.

Could it be that it’s because the feed.xml has a .xml ending? All other urls end in a path.
But that also would have to be a newly introduced behaviour since it worked fine before.
If I try .com/index.html and .de/index.html they get redirected and rewritten as expected

One more update after a few hours: Now the .com has the german feed file and the .de has the english one. Something is really wrong here.

It also is bugged for the sitemap. Currently .de/sitemap.xml and .com/sitemap.xml both lead to the .de sitemap. So it does seem to affect all .xml files with rewrites in subfolders.

Quick update: Everything seems to be in order again now. feed.xml and sitemap.xml get redirected and rewritten to the correct files in /en/ or /de/.

Can’t be sure though if its just randomly correct right now or fixed completely.

Let’s hope for the best.

1 Like

Well sadly it was just random. English page has german feed now again :frowning:
Lets hope they fix it or it fixes itself again…

It really is only a problem with xml files but not limited to the feed. Maybe it’s a problem in the CDN

Probably. A Netlify support member might take a look and confirm soon.

Hi folks,

I did spend a bit of time looking into this but couldn’t see it happening when I did nor was I able to do a lot of deep digging in retrospect without some more details.

Tobi, what we could use at this point is probably the x-nf-request-id (cf this article: [Support Guide] Netlify Support asked for the 'x-nf-request-id' header? What is it and how do I find it?) and hopefully a HAR file (https://toolbox.googleapps.com/apps/har_analyzer/) of you seeing it, since I couldn’t manage to reproduce it and our logs aren’t super clear about what is being served (once the files have been compressed, the english and german versions are pretty close in size so it isn’t very easy to pick out from our response_size logs which version is being served at which URL).

Thanks again for your help in troubleshooting!

Thanks for responding. Right now it appears to be fixed again, so I can’t reproduce either and therefore not provide anything to help. But I guess that’s a good thing. If it happens again I’ll look for the x-nf-request-id.