I have tested again. It seems it works HTTPS without added your line.
If I have also SUBdomain like subdomain.maindomain.com/…how to solve this option as your code reports an error:
The page isn’t redirecting properly
Browser has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.