title: Redirect Subdomain Using htaccess and Keep URL
body: <p>I have searched and while I found lots of threads close, none were exactly what I am looking for...</p>
  
  <p>On my site, say example.com, I've created the subdomain secure.example.com</p>
  
  <p>This subdomain will have SSL.</p>
  
  <p>What I want to do is redirect requests to <a href="https://secure.example.com/path/" rel="nofollow">https://secure.example.com/path/</a> to www.example.com/path/ while keeping the url showing as <a href="https://secure.example.com/path/" rel="nofollow">https://secure.example.com/path/</a></p>
  
  <p>note that the purpose of subdomain.example.com is for SSL so the redirect above will need to work with SSL</p>
  
  <p>I would like to use a few other redirects in the htaccess:
  1) redirect non-www to www ignoring subdomains (so secure.example.com doesn't become www.secure.example.com)
  2) redirect /index.php to /
  3) and last but not least, force SSL on secure.example.com</p>
  
  <p>In addition the shopping cart software has additional htaccess statements for functionality and SEO as seen below.</p>
  
  <h2>My current root htaccess:</h2>
  
  <pre><code># Prevent Directoy listing 
  Options -Indexes
  
  # Prevent Direct Access to files
  &lt;FilesMatch "\.(tpl|ini|log)"&gt;
   Order deny,allow
   Deny from all
  &lt;/FilesMatch&gt;
  
  # Turn Rewrite Engine On
  RewriteEngine On
  
  ## index.php to root
  Options +FollowSymlinks
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
  RewriteRule ^index\.php$ http://www.example.com/ [R=301,L] 
  
  ## non-www to www ignore subdomains
  RewriteCond %{HTTP_HOST} ^example.com [NC] 
  RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  
  RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
  RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
  RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
  </code></pre>