title: Apache RewriteRule pass entire URL as a parameter
body: <p>Currently my Apache <code>RewriteRule</code> only passes the path of the original URL as a query parameter to the rewritten URL.</p>
  
  <p>How do I send the entire URL (including scheme and authority etc) as a parameter to the rewritten URL?</p>
  
  <p>I know <code>%{REQUEST_URI}</code> only passes the path, and I can’t see any Apache environment variables that do pass the entire URL.</p>
  
  <p>I’m something of a beginner to Apache configuration so excuse any ignorance on my part,</p>
  
  <p>thanks!</p>
  
  <p>Here’s my current config:</p>
  
  <pre><code>#
  # Enable Rewrite
  #
  
  RewriteEngine On
  
  #
  # Condition for rewriting the URL. Check the URL's path is a valid REST URI path
  #
  
  RewriteCond %{REQUEST_URI} ^(?:[^?#]*)(?:/v[0-9]+(?:\.[0-9]+)*)(?:/[a-z]+)(?:/[a-z]+)(?:/?[^/?#]*)(?:[^?#]*)$
  
  #
  # Rewrite the URL, sending the REST path as a parameter to the specified version.
  #
  
  RewriteRule ^(?:[^?#]*)(?:/(v[0-9]+(?:\.[0-9]+)*))((?:/[a-z]+)(?:/[a-z]+)(?:/?[^/?#]*)(?:[^?#]*))$ https://localhost/rest/$1/index.php?request_uri_path=https://localhost/rest/$1/$2 [QSA,NC,L,R=307]
  </code></pre>
  
  <p>Currently I’ve hardcoded the url into the query parameters so the URL</p>
  
  <pre><code>https://localhost/rest/v1/users/show/12345
  </code></pre>
  
  <p>becomes:</p>
  
  <pre><code>https://localhost/rest/v1/index.php?request_uri_path=https://localhost/rest/v1/users/show/12345
  </code></pre>