point an A record of Domain to another server and redirect any http to https for that subdomain.

472 Views Asked by At

I have created an A record on my main domain that points to another IP address for a web application. Ex: account.mydomain.com has an A record that points to a third party server ex: 255.255.255.xxx

My issue is:
if someone goes to: http://account.mydomain.com they receive an error. if they go to: https://account.mydomain.com then it works.

I cant use a redirect because that subdomain is simply an A record. How can I fix this so http redirects to https only for that A record "account.mydomain.com"?

Thanks ahead of time for your help!

1

There are 1 best solutions below

4
On

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^account\.mydomain\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NC,R=301]