Redirect non www to www or vice versa (main domain, subdomain)

There is a project that requires me to make the following domain redirection Redirect all users to access the site WITHOUT the www. prefix for [...]