title: How to redirect non-www and www domain with specific sub folder to root?
body: <p><strong>I have 3 domain names:</strong><br></p>
  
  <pre><code>www.domain1.com
  www.domain2.com
  www.domain3.com
  </code></pre>
  
  <p><strong>They all share the same sub folder URL:</strong><br></p>
  
  <pre><code>www.domain1.com/sub1/sub2
  www.domain2.com/sub1/sub2
  www.domain3.com/sub1/sub2
  </code></pre>
  
  <p><strong>I need to redirect everything in sub2 and below it to the site's homepage:</strong><br></p>
  
  <pre><code>www.domain1.com/sub1/sub2  --&gt; www.domain1.com
  domain1.com/sub1/sub2 --&gt; www.domain1.com
  
  
  www.domain2.com/sub1/sub2  --&gt; www.domain2.com
  domain2.com/sub1/sub2 --&gt; www.domain2.com
  
  
  www.domain3.com/sub1/sub2  --&gt; www.domain3.com
  domain3.com/sub1/sub2 --&gt; www.domain3.com
  </code></pre>
  
  <p><strong>Here's what I have so far:</strong></p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^domain2\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^www\.domain2\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^domain3\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^www\.domain3\.com$ [NC]
  RewriteRule ^sub1/sub2(.*)$ / [NC,L,R=301]
  </code></pre>
  
  <p><strong>Problem:</strong><br>
  It's only working for <code>www.domain1.com, www.domain2.com, www.domain3.com</code>.</p>
  
  <p>It does not work for URLs without the "www".  So does not work: <code>domain1.com/sub1/sub2</code></p>
  
  <p>Thanks!</p>