]> granicus.if.org Git - apache/commitdiff
Adds a 'rewrite everything' or 'fallback resource' rule.
authorRich Bowen <rbowen@apache.org>
Sat, 21 Nov 2009 00:07:26 +0000 (00:07 +0000)
committerRich Bowen <rbowen@apache.org>
Sat, 21 Nov 2009 00:07:26 +0000 (00:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@882797 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/remapping.html.en
docs/manual/rewrite/remapping.xml

index 48981ace5163a8e530215681638842b54b08cf66..6ef1e53fcae6d01bd5d5dacb4e5f8d8299c70ffd 100644 (file)
@@ -46,6 +46,7 @@ configuration.</div>
 <li><img alt="" src="../images/down.gif" /> <a href="#canonicalurl">Canonical URLs</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual Hosts Per User</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#moveddocroot">Moved <code>DocumentRoot</code></a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#fallback-resource">Fallback Resource</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#mass-virtual-hosting">Mass Virtual Hosting</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#dynamic-proxy">Proxying Content with mod_rewrite</a></li>
 </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li><li><a href="access.html">Controlling access</a></li><li><a href="advanced.html">Advanced techniques and tricks</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div>
@@ -589,6 +590,55 @@ rather than rewriting URLs.</p>
 </dd>
 </dl>
 
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="fallback-resource" id="fallback-resource">Fallback Resource</a></h2>
+
+
+<dl>
+<dt>Description:</dt>
+<dd>You want a single resource (say, a certain file, like index.php) to
+handle all requests that come to a particular directory, except those
+that should go to an existing resource such as an image, or a css file.</dd>
+
+<dt>Solution:</dt>
+<dd>
+<p>As of version 2.4, you should use the <code class="directive"><a href="../mod/mod_dir.html#fallbackresource">FallbackResource</a></code> directive for this:</p>
+
+<div class="example"><pre>
+&lt;Directory /var/www/my_blog&gt;
+  FallbackResource index.php
+&lt;/Directory&gt;
+</pre></div>
+
+<p>However, in earlier versions of Apache, or if your needs are more
+complicated than this, you can use a variation of the following rewrite
+set to accomplish the same thing:</p>
+
+<div class="example"><pre>
+&lt;Directory /var/www/my_blog&gt;
+  RewriteBase /my_blog
+
+  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
+  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
+  RewriteRule ^ index.php [PT]
+&lt;/Directory&gt;
+</pre></div>
+
+<p>If, on the other hand, you wish to pass the requested URI as a query
+string argument to index.php, you can replace that RewriteRule with:</p>
+
+<div class="example"><pre>
+  RewriteRule (.*) index.php?$1 [PT,QSA]
+</pre></div>
+
+<p>Note that these rulesets can be uses in a <code>.htaccess</code>
+file, as well as in a &lt;Directory&gt; block.</p>
+
+</dd>
+
+</dl>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="mass-virtual-hosting" id="mass-virtual-hosting">Mass Virtual Hosting</a></h2>
index 142ea6dd06cdd9b8910631644e6955333d555969..8e87235019e6ff5f8b49fbc0566a523cd078a815 100644 (file)
@@ -159,8 +159,6 @@ Redirect /docs/ http://new.example.com/docs/
 
 </section>
 
-
-
 <section id="static-to-dynamic">
 
   <title>From Static to Dynamic</title>
@@ -593,6 +591,62 @@ rather than rewriting URLs.</p>
 
 </section>
 
+<section id="fallback-resource">
+<title>Fallback Resource</title>
+
+<dl>
+<dt>Description:</dt>
+<dd>You want a single resource (say, a certain file, like index.php) to
+handle all requests that come to a particular directory, except those
+that should go to an existing resource such as an image, or a css file.</dd>
+
+<dt>Solution:</dt>
+<dd>
+<p>As of version 2.4, you should use the <directive
+module="mod_dir">FallbackResource</directive> directive for this:</p>
+
+<example>
+<pre>
+&lt;Directory /var/www/my_blog&gt;
+  FallbackResource index.php
+&lt;/Directory&gt;
+</pre>
+</example>
+
+<p>However, in earlier versions of Apache, or if your needs are more
+complicated than this, you can use a variation of the following rewrite
+set to accomplish the same thing:</p>
+
+<example>
+<pre>
+&lt;Directory /var/www/my_blog&gt;
+  RewriteBase /my_blog
+
+  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
+  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
+  RewriteRule ^ index.php [PT]
+&lt;/Directory&gt;
+</pre>
+</example>
+
+<p>If, on the other hand, you wish to pass the requested URI as a query
+string argument to index.php, you can replace that RewriteRule with:</p>
+
+<example>
+<pre>
+  RewriteRule (.*) index.php?$1 [PT,QSA]
+</pre>
+</example>
+
+<p>Note that these rulesets can be uses in a <code>.htaccess</code>
+file, as well as in a &lt;Directory&gt; block.</p>
+
+</dd>
+
+</dl>
+
+</section>
+
 <section id="mass-virtual-hosting">
 
   <title>Mass Virtual Hosting</title>
@@ -668,6 +722,4 @@ ProxyPassReverse / http://old.example.com/
 
 </section>
 
-
-
 </manualpage>