title: How to get the same result with https:// starting subdomains too?
body: <p>We need a dynamically setup wildcard subdomain URL rewrite to our WordPress <code>.htaccess</code>. After digging on the web I have a nice one, but it works only with the default <code>http://</code> and it doesn't work correctly with the default <code>https://</code>.</p>
  
  <p>This method works now:</p>
  
  <pre><code>define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
  define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
  </code></pre>
  
  <p>with those pretags and it use the Affiliate WP default URL settings:</p>
  
  <blockquote>
    <p><a href="https://docs.affiliatewp.com/article/50-affiliate-urls" rel="nofollow noreferrer">https://docs.affiliatewp.com/article/50-affiliate-urls</a></p>
  </blockquote>
  
  <p>I am using the following code to dynamically get the user's webpages to know who referred the current purchase for the webshop:</p>
  
  <pre><code>RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/sponsor/%1/$1 [L,NC,QSA]
  </code></pre>
  
  <p>This code above works if I open the following URL for example:</p>
  
  <blockquote>
    <p><a href="http://johndoe.mydomain.com" rel="nofollow noreferrer">http://johndoe.mydomain.com</a></p>
  </blockquote>
  
  <p>It stays dynamic and it opens automatically with "https://" location.</p>
  
  <p>But it doesn't work if I want to open this URL like for example:</p>
  
  <blockquote>
    <p><a href="https://johndoe.mydomain.com" rel="nofollow noreferrer">https://johndoe.mydomain.com</a></p>
  </blockquote>
  
  <p>because it doesn't get the /sponsor/ rewriteRule.</p>