You can make it mandatory for users to divert traffic from the URL for www to non-www and vice versa with respect to your domain. If you are a cPanel customer, you can include an instruction to redirect users from www URLs to non-www or in your .htaccess file.
To redirect www to non-www URLs by using .htaccess
Step 1: Log into your account on cPanel.

Step 2: Edit or create an .htaccess file in the document root of your domain with the File Manager.

Step 2: In the Preference window that pops up, mark the Show Hidden Files(dotfiles) option and click on Save


Step 3: If you still don’t see the file click on File on the top left of the File Manager

Step 4: Enter .htaccess as the filename in the New File Name textbox.

Step 5: Enter a directory where you want to place the .htaccess file in the below section. The directory section is preconfigured to have “public_html” as the default selection.

Step 6: Now click on Create a New File


Step 3: This code should be added to the bottom of your file
# Redirect www URLs to non-www URLs - like http://www.yourdomain.com to http://yourdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]
Step 4: Click on Save Changes and Close.

To redirect non-www URLs using .htaccess
Step 1: Log into your account on cPanel.
Step 2: Edit or create an .htaccess file in the document root of your domain using The File Manager.
Step 3: Include this code in the final line of the document:
# Redirect non-www URLs to www URLs - like http://yourdomain.com to http://www.yourdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
Step 4: Click on Save Changes and Close.

Here’s an illustration of how the non-www redirect for URLs that are www after setting up the .htaccess file in cPanel.

Redirects to:
