title: Secure Url with mod_rewrite and symfony
body: <p>I have few pages which need to be secured through mod_rewrite and the code is based on mvc architecture</p>
  
  <p>Let me say I have a page login its url is <a href="http://www.example.com/login" rel="nofollow">http://www.example.com/login</a> it needs to be redirected to <a href="https://www.example.com/login" rel="nofollow">https://www.example.com/login</a></p>
  
  <p>If any url other than desired secured url uses https we need to change it to http for example
  <a href="https://www.example.com/sitemap" rel="nofollow">https://www.example.com/sitemap</a> must be redirected to <a href="http://www.example.com/sitemap" rel="nofollow">http://www.example.com/sitemap</a></p>
  
  <p>I am using the following code in .htaccess</p>
  
  <pre><code>  RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^login$ https://%{HTTP_HOST}/login [R=301,L]
  
    RewriteCond %{SERVER_PORT} ^443$
    RewriteCond %{REQUEST_URI} !^/login$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
  
    # we check if the .html version is here (caching)
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
  
    # no, so we redirect to our front web controller
    RewriteRule ^(.*)$ index.php [QSA,L]
  </code></pre>
  
  <p>The problem I get is, it gets looped where it says "server is redirecting the request for this address in a way that will never complete".</p>
  
  <p>Can you please help me out with the solution where only the following urls are secured and others are not. I need a solution with .htaccess and not with any symfony plugin.</p>
  
  <p><a href="https://www.example.com/login" rel="nofollow">https://www.example.com/login</a></p>
  
  <p><a href="https://www.example.com/account" rel="nofollow">https://www.example.com/account</a></p>
  
  <p><a href="https://www.example.com/register" rel="nofollow">https://www.example.com/register</a></p>
  
  <p>Thanks</p>
  
  <p>Nizam</p>