Our site was developed using www.ftso.com.au and we’ve recently acquired www.ftso.au and want to use it as our primary domain.
I have both domains registered externally added to Netlify.
Under Site Settings > Domain Management I have www.ftso.au as the primary domain with ftso.au “redirects automatically to the primary domain”
I have www.ftso.com.au and ftso.com.au listed as Domain Alias.
I want to do a 301 redirect for all pages so www.ftso.au/* is used in all instances.
I’ve created _redirects and it’s in my root folder and it contains the following …
Redirects from what the browser requests to what we serve
When I visit the .com.au the url remains the same, I’m expecting it to be .au only.
As per the Redirects and Rewrites documentation you need to save the
_redirects to the publish directory. Is the root directory where you have saved the
_redirects the directory that is published?
You will also want to follow the Domain-level Redirects documentation and create a wildcard rule so all paths are rewritten to the new URL not just the domain root.
Hello, my repository is github.com/fz22gq/ftsoau and it’s saved in the ftsoau folder.
I’ve read the documentation and wasn’t sure exactly what I had to do. I didn’t see an example relating to my scenario - hence the support question.
Unfortunately the repository is private
The file is in the root folder.
Is the root directory the directory that is published? What directory is set as the publish directory in the site build settings?
I see, that is _site/
I’ll move the “_redirects” file there, thanks.
Would this be the content in the _redirects file?
http://ftso.com.au/* https://ftso.au/:splat 301!
That is correct, except you shouldn’t need
https:// as all
http:// is automatically rewritten.
I’ve tried clearing cached and redeploying, which was successful, although I still don’t see the redirects working.
The _redirects file is in the _site folder and it contains …
https://ftso.com.au/* https://www.ftso.au/:splat 301!
https://www.ftso.com.au/* https://www.ftso.au/:splat 301!
Do you see something like this at the top of the deploy log?
Have to tried downloading the deploy to see if the
_redirects file is there?
Without knowing how you are building the site this is only a guess, but it is possible the
_site directory is created during the build process and anything in it overwritten. If this is the case, you may need to append a command such as
cp _redirects _site to the build command to ensure the file is in the deploy directory.
I don’t see anything at the start of the deploy log to suggest a redirect rule has been processed.
I’m autopublishing if that helps?
The _site folder exists in my local machine, but I don’t see it in Github, everything else is there.
I don’t see the option to download the deeply to verify the file exists.
Apologies for the vague answers, I’m inexperienced with Netlify and Github, I know just enough to get the site done.
I’ve added that line as you suggest, is this OK?
The deploy details page has changed a little since my previous screen capture. This is what you would look for now:
That build command won’t work. You would need
jekyll build --trace && cp _redirects _site (assuming jekyll overwrites
_site during build which I do not know as I don’t use it.) You may want to look at the Jekyll Documentation to see if there is another/better way to accomplish this.
OK, I was able to download the zip file, no there’s no _redirects file in there.
The log showed … No redirect rules processed
The deploy failed with that line added.
Unfortunately I do not know enough about Jekyll to provide a solution at this point @fz22gq.
From what I have read, Jekyll may treat files/directories starting with an underscore differently.
I know there are community member here with far more Jekyll knowledge and am sure they will have an answer for you in due course.
Thanks for the assistance. I’ve edited the subject to include Jekyll hoping to get the relevant eyes.
Now we’re getting somewhere. I’ve removed _site/ from the .gitignore file, will deploy again now.
Deploy successful, the _site folder now exists, as does the _redirects file.
Still showing “no redirect rules processed” in the deploy log.
Looking at your previous build, it seems that there was a
redirects.json file added but did not have the proper contents (and the file name should be _redirects).
Do you mind trying a whole different strategy here? Let’s try to add the redirects through a netlify.toml file. This file-based build approach will allow you to set/override multiple options on your build, being one of them the redirects.
In a netlify.toml file, each redirect has its own section. In your case:
force = true
force = true
The default HTTP status code for redirects is 301 so you don’t need to specify it there.
Can you try to apply this inside your netlify.toml file which needs to be created at the root level of your app.
With this approach you can remove the “cp” from your build command.
Can you try this out, please?