Issues with redirecting Netlify subdomain to main domain

I just built a new website with blogdown and Hugo and I'm using continuous deployment with Netlify from my Github. :heart_eyes: All is good except for the fact that my _redirects file (which is meant to redirect from my subdomain to my main custom domain) isn't working as intended -- i.e., https://harvardgwe.netlify.com/ is not redirecting to https://harvardgwe.com/.

Here is my Github repo that Netlify is deploying, which includes the aforementioned _redirects file.

PS: I have been looking around for working examples of _redirects files for other peoples' blogdown websites and think maybe multiple people are experiencing the same issue...? E.g., @apreshill, are your redirects working?

Appreciate the help! Thanks all!

Hey Alex,

Yes my redirects work, but yours does too I think? I see https://harvardgwe.com/ working, but perhaps I'm misunderstanding...

Thanks for responding! So, with the redirect I want people who type in https://harvardgwe.netlify.com/ to end up at the URL https://harvardgwe.com/ instead. Right now if you go to the netlify subdomain it doesn't redirect to the primary domain. See below:

Does that make sense?

Ah yes - so it is publishing the site to the correct domain because in your config.toml file you have baseURL = "https://harvardgwe.com/". Check out Yihui's redirects file- it may be that it needs to be in static? I forgot I moved mine to the root and it looks like it is having your same problem :wink:

3 Likes

Word, I moved the _redirects file to static/ and that worked!! Problem solved.
Thank you, @apreshill! :upside_down_face:

1 Like

now to go fix mine so I don't keep setting a bad example!!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.