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