If you have apache/mod_rewrite installed put this in your .htaccess
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
</IfModule>
Otherwise you can use php in this way:
Code:
if ($_SERVER['HTTP_HOST']=='www.domain.com')
header("Location: https://domain.com".$_SERVER['REQUEST_URI']);