title: Rewriting Root Directory Path "/" for Javascript
body: <p>We can modify the document root directory path for PHP using </p>
  
  <pre><code>$_SERVER['DOCUMENT_ROOT'] = "to/some/new/directory";
  //Now the "/" which represent the ^(above) path
  </code></pre>
  
  <p>in .htaccess we have</p>
  
  <pre><code>RewriteBase "/to/some/new/directory"
  </code></pre>
  
  <p>Now, I need to modify the root directory path to use in javascript. How to do it?</p>
  
  <p>Currently, I am declaring a variable containing static path to the my personalized root directory and using it as</p>
  
  <pre><code>var root = "../to/new/path";
  document.location = root+"/somepage.php";
  </code></pre>
  
  <h1>Scenario</h1>
  
  <p>I think i should tell a little bit about the scenario, for you guys to catch my idea</p>
  
  <p>Default Web Root Directory</p>
  
  <pre><code>http_docs/
  </code></pre>
  
  <p>inside it contain a main folder</p>
  
  <pre><code>http_docs/application &lt;-- contains the actual application
  http_docs/js &lt;-- contains the script
  http_docs/index.html
  </code></pre>
  
  <p>Now, the application also contains ajax feature for updating, editing, loading new content, or other resources, which if accessed at "/" will represent at /some/path/i/called not /application/some/path/i/called,</p>
  
  <p>To come around this problem 
  I can define a static variable like</p>
  
  <pre><code>var root = "application/";
  </code></pre>
  
  <p>and use it somewhere like</p>
  
  <pre><code>$.post(....., function(data) { $(body).append("&lt;img src='"+root+"resources/img1.jpg"); });
  </code></pre>
  
  <p>But for a single use, defining the path as static, might not be a big deal, but, when the application grows, and certain modification would cause me to change all the paths i give in the js part. I thought, it would be sensible, just like, I do it in PHP, using <code>&lt;img src="/resources/img1.jpg" /&gt;</code></p>
  
  <p>I tried my best to explain this question, if still is not understandable, please community, lets help them understand. I welcome you to edit my question. </p>