title: Redirecting http urls to https
body: <p>There are many example of making all <code>http</code> redirects to <code>https</code>. </p>
  
  <pre><code>Options +FollowSymlinks
  RewriteEngine on
  RewriteBase /
  
  RewriteCond %{SERVER_PORT} !^443$ 
  
  RewriteCond %{HTTPS}  off 
  RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
  </code></pre>
  
  <p>However, I would like to redirect only those URLs that are coming from a web browsers. As many functions are being used in API calls for mobile applications, hence I can't use the above code as it redirects all urls to https and the APIs calls make the mobile apps crash.</p>
  
  <p>How can I modify the above code, so as to redirect only those URLs thast are coming from a web browser?</p>