Correct file location for redirects file - redirects not working as expected

Hi,

I want to redirect https://rakshitsoral.netlify.com to my domain https://rakshitsoral.ga

As per the documentation, I have added _redirects file to the root folder of my site domain. But it isn’t working, not sure about the reason.

Is there any way to redirect both the URLs.

FYI: My github pages site is on Netlify CMS.

What are the contents of the _redirects file?

Here it is:

These rules will change if you change your site’s custom domains or HTTPS settings

Redirect default Netlify subdomain to primary domain

https://rakshitsoral.netlify.com/* https://rakshitsoral.ga/:splat 301!

Looks fine to me. Is it possible for you to share the link to your repo? May be you have filename wrong or incorrect format etc.

sure, here it is: https://github.com/rakshitsoral/one-click-hugo-cms

You need to put _redirects file in site/static/ directory. That way after build it’ll end up in root of your published site.

1 Like

Oops, my bad. Thanks for your help.

Redirect is not working after doing the same @rootkea
And one thing more, I don’t know why but when I make some changes on site like “adding the title tag for SEO”, it’s not reflecting when i commit from the repo. Do you know the reason behind it?

@rakshitsoral, looking at your currently published deploy, you don’t have a _redirects file. When you build the site locally on your own machine does the _redirects file exist in the root of your publish directory?

1 Like

_redirects file is in the admin folder. But I have found the reason behind it. It seems that my deploys have failed that’s why there are no changes made live. I have raised the question here in the forum.

Here’s the link to failed deploy: Netlify App

So we can keep the forum organized I won’t respond in this thread about the build errors :wink:

However, the _redirects file must end up next to your index.html in the root of your build directory when your build completes (in gatsby’s case, it will move the files in static to that folder for you :))

We do NOT read it from anywhere else.

Good day futuregerald

Should my _redirects file be located in my public directory?

Thank you

Hi, @JoeMark, and welcome to our Netlify community site.

The _redirects file should be in the publish directory for your site. The “publish directory” is where your sites files are stored after the site is built.

For some static site generators, that directory is indeed named “public”. If this is the correct directory for you or not will depend on what directory your static site generator (SSG) uses for storing the files created during the build process.

Let me take Hugo as an example.

Hugo deletes the contents of “public” before building and then stores all built files there. However, any files included in the directory “static” are copied to “public” during the build. So, for Hugo you should put the files in “public”.

There are two ways to do this. You can either manually copy the file there as the last step of the build or keep the file in “static” and Hugo will copy it to “public” for you automatically. (If you are using Hugo, I recommend doing it this second way).

If you tell us which SSG you are using, we can give an answer specific to that SSG. ​Please let us know if there are other questions about this and we’ll be happy to answer.

1 Like

Dear Luke

Thank you for your kind welcome and detailed explanation.
I have resolved my error. My domain hosting service provider was able to assist and my site, once again, launches seamlessly.

Kind regards
Joe-Mark Lippert