Only first redirect rule seems to fire

Hi,

I have a Hugo app hosted at https://zamaneh-splash.netlify.com/ and https://splash.radiozamaneh.com/. The app is served from the public folder. In this public folder I have the a _redirects file with three rules:

# Redirect default Netlify subdomain to primary domain
https://zamaneh-splash.netlify.com/*  https://splash.radiozamaneh.com/:splat  301!

/article  https://www.example.org/article 303!

# Redirect all other clients to radiozamaneh.com
/*  https://www.radiozamaneh.com 303

The first (and only the first) redirect rule fires correctly. The /article redirect returns a Netlify 404 page as does every other path except the root, which correctly returns index.

This makes me think that only the first redirects rule ever fires for some reason. I’m a bit confused. Any takers?

Many thanks for you help!

Hi @Marcel,

Looking at your current deploy, you don’t have a redirect for /article:

# Netlify redirects are managed as a separate content type

# Redirect default Netlify subdomain to primary domain
https://zamaneh-splash.netlify.com/*  https://splash.radiozamaneh.com/:splat  301!

# Temporary redirect for Article19
https://splash.radiozamaneh.com/article19  https://www.article19.org/fa/resources/%D8%A7%DB%8C%D8%B1%D8%A7%D9%86%D8%A8%D8%B1%D8%B1%D8%B3%DB%8C-%D8%AF%D9%88%D8%B1%D9%87%E2%80%8C%D8%A7%DB%8C-%D9%87%D9%85%DA%AF%D8%A7%D9%86%DB%8C-%D9%BE%DB%8C%D8%B4-%D8%B1%D9%88-%D8%A8/ 303!

Are you sure you deployed that redirect?

Thanks @futuregerald,

I didn’t post the real content of the _redirects file because it didn’t need that to be public knowledge. That’s why I slightly rewrote the /article19 rule for illustrational purposes :thinking:

My questions concerns that rule though. It’s not firing at the moment.

Cheers,
Marcel

Could it be the use of the full domain in the redirect?

Maybe if you did:

/article19  https://www.article19.org/... 303!

I’m afraid not. I tried that first but since that wasn’t working I tried to use a fully qualified URL instead. It seems neither are working in this case.

I guess it could be the URL. Does it work with a URL without all the escapes (e.g. “https://example.com/”)?

If so, looks like it might be a Netlify redirect parsing bug.

Thanks for the suggestion. I tried like this:

/article19 https://www.article19.org/ 303!

but no luck. I honestly haven’t a clue why this isn’t working as advertised. Maybe I’ve been staring at this and I’ve been missing a syntax error all this time, but I don’t see it :frowning:

Ah, while I do see that redirect “deployed” now (in our database attached to your site), I think it is not working due to the 303 status. We only support 301 and 302. Could you try one of those and let me know if it works better?

Thanks @fool for the catch! I changed the redirect to a 302 and now everything works as advertised.

May I make a suggestion? The Netlify documentation at the least strongly suggests that 303 redirects are supported to:

When the status code is 301 , 302 , or 303 , Netlify will redirect to the target URL. With any other status code Netlify will render the target URL with the specified status code.

I took this from https://www.netlify.com/docs/redirects/#http-status-codes; this is obviously wrong, I’d argue.

Also, I’d ask that you look into supporting additional redirect status codes in the 300 range. In my case 303 has the correct (client-side) semantics while its server side implementation should be exactly the same as that of 302.

In any case, thanks so much for your help.

Kind regards,

Thanks for pointing out that discrepancy in the documentation, @Marcel. I flagged this for follow-up and our documentation team will be examining this.

To everyone here in the community, please always feel free to point out documentation issues here. We deeply value the quality of our docs and have processes in place to get them corrected when any issues are noticed.