HTTP links not triggering netliy.toml redirect rules

For some strange reason, http www links aren’t triggering my netlify.toml’s redirection rules no matter how many rules I’m adding. What could be the issue?

Website:
https://www.confluencerecording.org/

Context:
http://universalmusicdesign.org is a Domain alias for http://www.confluencerecording.org

https://universalmusicdesign.org/ works as expected, redirecting to Universal Music Design

http://www.universalmusicdesign.org doesn’t work as expected, it goes to http://www.confluencerecording.org instead of the Universal Music Design page.

Pretty strange because in my nelify rules, the last item is from http://www.universalmusicdesign.org to https://www.confluencerecording.org/universalmusicdesign .

My nelify.toml are as follows:

[build]
  publish = "."

[[redirects]]
  from = "https://universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "http://universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "www.universalmusicdesign.org"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "http://www.universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

All four rules are detected by netlify:
image

This entire thing have made me to wish that there was an offline way to quickly test that redirect rules are working as expected… Building the website over and over to test each little tweak is eroding away my soul, heh.

Anyway, do anyone know what could be wrong here?

http://www.universalmusicdesign.org/ will automatically redirect to https://www.universalmusicdesign.org/ when SSL is enabled and as far as I know there is no way to override this.

The redirect https://www.universalmusicdesign.org/ isn’t working correctly as it is going to https://www.confluencerecording.org/and not to the path specified.

$ curl -sIL http://www.universalmusicdesign.org/ |egrep -i '^(HTTP|location)'
HTTP/1.1 301 Moved Permanently
Location: https://www.universalmusicdesign.org/
HTTP/2 301
location: https://www.confluencerecording.org/
HTTP/2 200

The redirect https://universalmusicdesign.org/ is working as intended

$ curl -sIL http://universalmusicdesign.org/ |egrep -i '^(HTTP|location)'
HTTP/1.1 301 Moved Permanently
Location: https://universalmusicdesign.org/
HTTP/2 301
location: https://www.confluencerecording.org/universalmusicdesign
HTTP/2 200
1 Like

Just got an email from the SavvyBot. This post is still unresolved. Dig’s reply was to provide more information on what’s happening under the hood. Is Netlify support able to help with this issue?

" SavvyBot here from the Netlify forums.

This is an automated message - we saw you posted a question in our forums which is likely solved, but we didn’t see you mark a solution. Marking questions as solved greatly helps other people find answers to their questions.

Please pick a solution by activating the checkbox you can see underneath the post that solves your question:

Checkbox underneath a post that marks it as the solution|autoxauto

These are the question(s) we found that do not have a solution:

Question not solved? Let’s get you some more help. Please post again in the thread so we can keep assisting!"

Hi, @DillonSimeone. Netlify tries to be HSTS Preload list compatible. There is more about HSTS Preload here:

https://hstspreload.org/

One of the requirements is this:

  1. Redirect from HTTP to HTTPS on the same host, if you are listening on port 80.

Netlify will redirect from HTTP to HTTPS will occur with no other changes to the URL first. Only after that automatic redirect will other redirects be processed. If you make those redirects from HTTPS to HTTPS they should work as required. If no, please let us know the URL which doesn’t redirect as required.

(Think I forgot to use reply in the deleted post…)

Making sure that I understand what you said, @luke ,

It’s EXPECTED that http getting upgraded to https would result in redirects rules for the https to not be applied to the url?

Copy paste from my initial post:
http://www.universalmusicdesign.org doesn’t work as expected, it goes to http://www.confluencerecording.org instead of the https://www.confluencerecording.org/universalmusicdesign

The desired behavior is for http://www.universalmusicdesign.org to redirect to https://www.confluencerecording.org/universalmusicdesign, as listed in the .toml. Is that impossible?

Hi, @DillonSimeone. About this:

No, it isn’t impossible but you must take into account the HSTS rule of:

  • http://www.universalmusicdesign.org/ will always redirect to https://www.universalmusicdesign.org/ first

You cannot escape that rule above at Netlify. The solution is to make the redirects use https:// only as those are the only URLs your redirect rules will trigger for.

So, why isn’t it working? The answer is because some of the redirect rule have errors. Here is the netlify.toml file from the current deploy:

[build]
  publish = "."

[[redirects]]
  from = "https://universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "http://universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "www.universalmusicdesign.org"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "http://www.universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

These two redirects will never trigger because they are on http:// URLs and not https:// URLs:

[[redirects]]
  from = "http://universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

and:

[[redirects]]
  from = "http://www.universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

Those two above will do nothing so they should be deleted.

Next, this redirect is missing a scheme (http:// or https://) completely:

[[redirects]]
  from = "www.universalmusicdesign.org"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

The from is "www.universalmusicdesign.org". That is a domain name but not a URL.

The correct format would be:

[[redirects]]
  from = "https://www.universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

With all the edits suggested above, the new netlify.toml file would look like this:

[build]
  publish = "."

[[redirects]]
  from = "https://universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

[[redirects]]
  from = "https://www.universalmusicdesign.org/"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

However, there is one last problem. The domain www.universalmusicdesign.org has not been added to the sites domain management settings.

If you add the domain www.universalmusicdesign.org to the site’s settings, the redirects in the final netlify.toml file above will work as required.

Can you clarify on how I should be adding the domain to the site’s settings? Screenshots below of my settings:

In the panels above, I don’t see any different ways to add universalmusicdesign.org to the site other than as an alias.

@luke

Aha, after thinking about it for a bit, I removed universalmusicdesign.org as an alias of confluencerecording.org, and span up an entirely new website.

That new website only have a .toml in it, no index.html, etc…

[build]
  publish = "."

[[redirects]]
  from = "*"
  to = "https://www.confluencerecording.org/universalmusicdesign"
  status = 301
  force = true

www.universalmusicdesign.org AND https://universalmusicdesign.org now correctly redirects to https://www.confluencerecording.org/universalmusicdesign

I feel like this is a dirty hack. Is this how it was supposed to be done in the first place?

I’m not sure what made to remove the domain alias and move to the other site. You should be able to keep it as a domain alias and still add those redirects.