title: How to write the rewrite js, css, img rule for domain and IP address by reusing the current rule?
body: <p>This is my current rule</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteRule ^$ public/     [L]
      RewriteRule (.*) public/$1 [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>This rule will rewrite all url to public folder</p>
  
  <p>www.xxx.com/js/main.js -> www.xxx.com/public/js/main.js</p>
  
  <p>123.123.123.123/site_folder/js/main.js -> 123.123.123.123/site_folder/public/js/main.js</p>
  
  <p>Now I want to add some rules for js, css, img</p>
  
  <p>e.g.</p>
  
  <pre><code>src="/js/main.js"
  src="/css/main.css"
  src="/img/test/png"
  </code></pre>
  
  <p>When URL is domain, no need to rewrite "www.xxx.com"</p>
  
  <pre><code>src="/js/main.js" -&gt; www.xxx.com/js/main.js
  </code></pre>
  
  <p>If URL is IP, rewrite to site folder URL "123.123.123.123/site_folder"</p>
  
  <pre><code>src="/js/main.js" -&gt; 123.123.123.123/site_folder/js/main.js
  </code></pre>
  
  <p>After the first rewrite, use this current rule to rewrite again</p>
  
  <pre><code>RewriteRule ^$ public/     [L]
  RewriteRule (.*) public/$1 [L]
  
  www.xxx.com/js/main.js -&gt; www.xxx.com/public/js/main.js
  123.123.123.123/site_folder/js/main.js -&gt; 123.123.123.123/site_folder/public/js/main.js
  </code></pre>
  
  <p>So that I just need to modify the current if I rename the public folder.</p>
  
  <p>Is it possible to do all above?</p>