title: Remove www site-wide, force https on certain directories and http on the rest?
body: <p>Firstly, I would like to remove the www. from my domain name</p>
  
  <p><a href="http://www.example.com" rel="noreferrer">http://www.example.com</a> => <a href="http://example.com" rel="noreferrer">http://example.com</a></p>
  
  <p>I would also like for certain directories to be secure (https), while the rest remain http</p>
  
  <p><a href="http://example.com/login" rel="noreferrer">http://example.com/login</a> => <a href="https://example.com/login" rel="noreferrer">https://example.com/login</a></p>
  
  <p>Obviously it needs to work for all conditions, for example if someone types in:</p>
  
  <p><a href="http://www.example.com/login" rel="noreferrer">http://www.example.com/login</a> => <a href="https://example.com/login" rel="noreferrer">https://example.com/login</a></p>
  
  <p>Also when people navigate away from the login page it returns to http. Currently in the .htaccess is the following which is done automatically by the software I am using and I suppose needs to be there for it to work:</p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule .* ./index.php
  </code></pre>
  
  <p>Any ideas on how I can achieve <strike>dream control</strike> all these things?</p>
  
  <p>Thanks in advance!</p>
  
  <p>===================</p>
  
  <p>@Gumbo Following your advice this is my complete .htaccess</p>
  
  <pre><code>RewriteEngine On
  
  
  # remove www from host
  RewriteCond %{HTTP_HOST} ^www\.(.+)
  RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
  RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]
  
  # force HTTPS
  RewriteCond %{HTTPS} =off
  RewriteRule ^(login)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  # force HTTP
  RewriteCond %{HTTPS} =on
  RewriteRule !^(login)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule .* ./index.php
  
  
  Options -Indexes
  </code></pre>
  
  <p>Navigating to <a href="http://example/login" rel="noreferrer">http://example/login</a> still goes to <a href="http://example/index.php" rel="noreferrer">http://example/index.php</a> when it should go to <a href="https://example/login" rel="noreferrer">https://example/login</a> Do I have the order wrong?  </p>