RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The differrences are:
- Specify port 80 not any port containing 80 as digits in the port number.
- Specify mail.fancyblue.net using No Case.
- If both conditions are met, redirect the {REQUEST_URI} to the secure server without duplicating Apache variables for {HTTP_HOST} and {REQUEST_URI}; any query string will not be affected.