Redirect www to non-www under subdomain

Hi,

I have set redirect from http to https under Virtuamin configuration, now I would like to redirect for all vhosts www to no-www. Is there a setting somewhere?

Under vhost tried:

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

but it doesn’t work for subdomain

Thanks,

A sub domain shouldn’t have www, This can be set in your sub-domains directives Services -> Configure Website -> Edit Directives and remove the line that says ServerAlias www.. You should do the same for SSL if your site is running as an SSL site.

Hi thanks for the answer, removed the line, however still it is possible to access: https://www.mydomain.com it does not redirect to https://mydomain.com

Mine does that by default. If you go to your site via www.mydomain.com does it not automatically redirect you to mydomain.com without the www?

Also, after you removed the line did you click the “Apply Changes” button in the top right corner to apply your changes?

Yes I did restart Apache, please notice, that I have http to https redirection set under Virtualmin configuration maybe that is why is not working?

Can you post the domain name?

Is here a messaging system? :slight_smile: I do not want to share domain on public forum

Doesn’t look like it.