Netlify Redirects - 2 URLs into 1

Hi All,

I’ve searched for help on this, and expected to find some because it doesn’t seem too out of the ordinary, but failed.

I have deployed my site to Netlify.
I have a _redirects file which has 22 entries.
In the deployment on Netlify, I can see it has processed 22 entries.
So far so good.

Two of the entries point to the same page.

/ContactUs.aspx /contact
/AddReview.aspx /contact

Netlify seems to process the two rules, but only the second one works.
I have swapped them round and still the same, only the second works.

Is what I am trying to do possible? This seems a pretty straight forward thing to do.

Thanks

Yes it’s definitely possible. Did you forcing the rules like this: /ContactUs.aspx /contact 301!?

Thanks for your help - unfortunately that doesn’t work.

I have read this in the docs but this talks about the first part of the redirect - not the second part:

" The redirects engine will process the first matching rule it finds, reading from top to bottom. Rules in the _redirects file are always processed first, followed by rules in the Netlify configuration file."

Hi, @haribo85. It should work the way you have the rules written. If you tell us the URL that isn’t redirecting we can troubleshoot to find out why.

Thanks for reaching out.

The site is here:
https://b6b818c2-48cb-4f06-bdc4-58710e2c1f5d.netlify.app/

This redirect works:
https://b6b818c2-48cb-4f06-bdc4-58710e2c1f5d.netlify.app/AddReview.aspx

This redirect doesn’t:
https://b6b818c2-48cb-4f06-bdc4-58710e2c1f5d.netlify.app/ContactUs.aspx

Here are the rules:
/ContactUs.aspx /contact 301!
/AddReview.aspx /contact 301!

Thanks

Anymore ideas on this?

Hey @haribo85 ,

I’ve taken a look and it looks like our redirects engine has parsed the first rule in your redirects file incorrectly! I’m not 100% sure why it has done this but I would encourage you to remove the tabular indents in your _redirects file.

e.g. please try:

/ContactUs.aspx /contact 301!
/AddReview.aspx /contact 301!
/Music.aspx /music 301!
etc.

1 Like

Hey @Scott

Thanks for looking into this.

I’ve just made that change, but unfortunately it’s still the same.

Any other ideas?

Okay, bare with me on this but is there any chance you can flip the rules in your file, please? Put the AddReview rule above ContactUs?

I think I can see a parsing error and I want to know if it’s impacting the first rule in your file, or specifically the ContactUs rule!

As I stated at the top, no matter what order I put these two rules in, it’s always the second one that works.

I have just switched them around though as you asked for, and the same thing happens.

I’m not sure whether you have access to, but feel free to change the _redirects file yourself if it will help with debugging. The site is not live yet and I have no problem with you making changes if it will help speed up the fix.

Thanks

Hey @haribo85 ,

The only difference between your site and other, working _redirects files is that your lines are wrapped with \r\n. This is a Windows versus Linux/Mac nomenclature difference.

Can I ask that you edit the file, ensuring that the \r character isn’t captured?

2 Likes

Well, well, well! That’s only gone and fixed it!

I’ll be honest, I didn’t hold out much hope for that as all the other rules worked, I wondered why that would make a difference.
I also thought I can’t have been the only person to have tried this on a Windows machine and it fail.

But regardless, the redirects now work.

Thanks for all your help.

2 Likes