title: URL Rewrite rule based on certain conditions
body: <p>I am in process to apply URL rewriting rule based on certain condition in my .htaccess file but have got struck due to my near to zero level knowledge of URL rewriting using Apache .htacces.Here is my use case</p>
  
  <p>i have few plugins in my WordPress application and those plugins making use to certain CSS and JavaScript,all i want that those URLs should be served from the CDN server, due to some issues i can not use a simple rewrite which will rewrite the URL for entire application as that thing is breaking my application functionality.</p>
  
  <pre><code>http://www.mydomain.com/wp-content/plugins/pluginA/abc.css
  http://www.mydomain.com/wp-content/plugins/pluginA/abc.js
  </code></pre>
  
  <p>i want that when the CSS and JS are from this plugin (Plugin A ) or any other plugin whose URL i want to rewrite, The URL should get rewritten as</p>
  
  <pre><code>http://www.cdn.mydomain.com/wp-content/plugins/pluginA/abc.css
  http://www.cdn.mydomain.com/wp-content/plugins/pluginA/abc.js
  </code></pre>
  
  <p>i am not sure how to do such conditional based URL rewriting,Any suggestion will really be 
  helpful</p>
  
  <p><strong>Edit</strong>
  This is my current .htaccess file in the root </p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /wordpress/
  RewriteCond %{QUERY_STRING} (\&lt;|%3C).*script.*(\&gt;|%3E) [NC,OR]
  RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
  RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /wordpress/index.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>i have created a new <code>.htaccess</code> file under <code>wp-content</code> folder as per <code>Michael</code> suggestion with following entry</p>
  
  <pre><code>RewriteEngine On
  &lt;IfModule mod_rewrite.c&gt;
  RewriteBase  /wordpress/
  RewriteCond %{REQUEST_FILENAME} ^.+\.(css|js)$
  RewriteRule wp-content/plugins/(nivo-slider-light|Usernoise|lightbox-plus|wp-content-slideshow|content-slide)/(.+)$ http:/cdn.cloudfront.net/wp-content/plugins/$1/$2 [L,R=302,QSA]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>but seems this is not working as still for the above plugins all the css and js file are being served with the URL from localhost and not from my CDN server.I even commented out these lines from my root's .htaccess file</p>
  
  <pre><code> RewriteCond %{QUERY_STRING} (\&lt;|%3C).*script.*(\&gt;|%3E) [NC,OR]
   RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
   RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
  </code></pre>
  
  <p>but this also did not made any changes in the URL</p>