@bobnoordam

Generic www tot non www redirect for apache

Step 1, Make sure you can use mod_rewrite

The virtual host you want to apply the redirection on needs permissions to use mod_rewrite to perform the redirection. You will need something along these lines a little bit dependent on how your websites are configured to enable overriding options through .htaccess

<Directory /home/yoursite/www>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        Allow from all
</Directory>

Step 2, Applying the redirect

Edit or create the .htaccess file in the web directory for the site, and add the following redirect code

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]