title: Asp.net mvc 301 redirect
body: <p>I have one website with ssl certificate.
  The domain is <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a>
  I have one sub domain <a href="http://api.example.com" rel="nofollow noreferrer">http://api.example.com</a> which has not ssl certificate.</p>
  
  <p>So i want to redirect my <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a> to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a> using web.config MVC.</p>
  
  <p>When I am doing this, the subdomain is also redirect 301.</p>
  
  <p>I want to redirect only my main domain.</p>
  
  <p>My code is as below:</p>
  
  <pre><code>&lt;rewrite&gt;
        &lt;rules&gt;
          &lt;rule name="Redirect-HTTP-HTTPS-IIS"&gt;
            &lt;match url="(.*)" /&gt;
            &lt;conditions&gt;
              &lt;add input="{HTTPS}" pattern="^OFF$" ignoreCase="true" /&gt;
            &lt;/conditions&gt;
            &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /&gt;
          &lt;/rule&gt;
        &lt;/rules&gt;
      &lt;/rewrite&gt;
  </code></pre>