Can't redirect no www to www

Hi folks, I want the no www version of my website to redirect to the www. version. I have tried every solution suggested in this forum and none of them seem to work, no www is still returning a 404 while www works perfectly.

My Caddyfile currently looks like this:

oahspesales.com, www.oahspesales.com {
  root  public  # the folder where Hugo generates the website
  hugo          # enable the admin panel
  redir 301 {
    if {host} starts_with oahspesales.com
    / https://www.oahspesales.com{uri}
  }
}

Caddy runs fine without any errors, but refuses to serve a web page on https://oahspesales.com.

What should I do?

UPDATE: Nevermind, it works fine now. Is there no way to delete a post?

… and of course the moment I ask for help, it magically starts working. I hate computers.

1 Like

I think what I changed is that in config.toml for Hugo, I changed my baseurl to the www version.

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