Is 301 redirect from to primary domain possible?

I have a primary domain https://www.mymringredient.com/, when I inspect my current urls I notice there is url that starts without www, for example https://mymringredient.com/Recipes and this will be redirect with 307 as shown in the image below:

My question is that if there is any way to change 307 redirect into 301 redirect?
Such that https://mymringredient.com/Recipes will be redirect to https://www.mymringredient.com/Recipes with 301 redirect. Is that possible ?

I wrote the following in netlify.toml

[[redirects]]
    from = "https://mymringredient.com/*"
    to="https://www..mymringredient.com/*"
    status=301

is that the correct way to do what I wanted ? If so do i need to do this for http:// as well ?

I’m not sure if you can use 301 redirect to primary domain in this way, but if at all you can, the redirect rule should be setup like this:

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

Also, about the question for http://, I don’t think so. Netlify redirects to HTTPS atomatically, so it should work.

I need a way to change the 307 redirect from http to https to a 301. I’ve tried the following:

[[redirects]]
    from = "http://stormbrands.co/*"
    to = "https://stormbrands.co/:splat"
    status = 301

I’m still getting a 307 though which is wrong. How can this be done?

You can try adding force = true to see if it makes a difference. I’m not sure if it does, but if at all there’s a way then it’s that.

If it doesn’t work, well there’s no other way sadly.

1 Like

Perfect, that worked! Thank you