title: Using htaccess to drop ?tag= from the end of all URLs
body: <p>This is my last task with my ecommerce website and I now need to drop <code>?tag=shirts</code>, <code>?tag=hoodies</code> and <code>?tag=tanks</code> from all URLs using htaccess. The url works perfectly with or without the ?tag at the end so its just a matter of cosmetics and consistency across the site. I cannot just drop "shirts", "hoodies" and "tanks" from any URL because my categories are domain.com/shirts/", "domain.com/hoodies/" and domain.com/tanks/" so it has to explicitly contain the "tag=" prefix in the condition.</p>
  
  <p>For example:</p>
  
  <pre><code>https://www.domain.com/animals/awesomeproduct32/?tag=shirts
  https://www.domain.com/animals/awesomeproduct5/?tag=hoodies
  https://www.domain.com/animals/awesomeproduct3/?tag=tanks
  </code></pre>
  
  <p>I want the ?tag part dropped off in ALL circumstances (and remember, that this will not create any 404's so it's totally fine):</p>
  
  <pre><code>https://www.domain.com/animals/awesomeproduct32/
  https://www.domain.com/animals/awesomeproduct5/
  https://www.domain.com/animals/awesomeproduct3/
  </code></pre>
  
  <p>Please note that the category name (in this case, its "animals") and the product name is variable.</p>
  
  <p>Here is my htacess file (big thanks to @anubhava for all his help with this):</p>
  
  <pre><code># remove /design/ from URLs and redirect
  RewriteCond %{THE_REQUEST} \s/+design/(\S*)\s [NC]
  RewriteRule ^ /%1 [R=301,L,NE]
  
  # internally add design/ to know set of URIs
  RewriteRule ^(skulls-bones|characters|abstract|animals|games|geek-nerd|graphic|keep-calm|movies-tv|pop-culture|tattoo|typography)(/.*)?$ design/$1$2 [L,NC]
  
  # external redirect from actual URL to pretty one
  RewriteCond %{THE_REQUEST} \s/+product/search/\?tag=([^\s&amp;]+) [NC]
  RewriteRule ^ /%1/? [R=301,L,NE]
  
  # internal forward from pretty URL to actual one
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !^/design/ [NC]
  RewriteRule ^([^/]+)/?$ product/search/?tag=$1 [L,QSA]
  </code></pre>
  
  <p>My only concern is making sure that this dropping of the ?tag doesn't interfere with my other rules.</p>
  
  <p>Thanks!</p>