
rbowen at apache
Nov 20, 2009, 4:07 PM
Post #1 of 1
(151 views)
Permalink
|
|
svn commit: r882797 - in /httpd/httpd/trunk/docs/manual/rewrite: remapping.html.en remapping.xml
|
|
Author: rbowen Date: Sat Nov 21 00:07:26 2009 New Revision: 882797 URL: http://svn.apache.org/viewvc?rev=882797&view=rev Log: Adds a 'rewrite everything' or 'fallback resource' rule. Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en httpd/httpd/trunk/docs/manual/rewrite/remapping.xml Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en?rev=882797&r1=882796&r2=882797&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en Sat Nov 21 00:07:26 2009 @@ -46,6 +46,7 @@ <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> @@ -591,6 +592,55 @@ </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> +<Directory /var/www/my_blog> + FallbackResource index.php +</Directory> +</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> +<Directory /var/www/my_blog> + RewriteBase /my_blog + + RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f + RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d + RewriteRule ^ index.php [PT] +</Directory> +</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 <Directory> 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> Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.xml?rev=882797&r1=882796&r2=882797&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/remapping.xml (original) +++ httpd/httpd/trunk/docs/manual/rewrite/remapping.xml Sat Nov 21 00:07:26 2009 @@ -159,8 +159,6 @@ </section> - - <section id="static-to-dynamic"> <title>From Static to Dynamic</title> @@ -593,6 +591,62 @@ </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> +<Directory /var/www/my_blog> + FallbackResource index.php +</Directory> +</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> +<Directory /var/www/my_blog> + RewriteBase /my_blog + + RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f + RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d + RewriteRule ^ index.php [PT] +</Directory> +</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 <Directory> block.</p> + +</dd> + +</dl> + +</section> + <section id="mass-virtual-hosting"> <title>Mass Virtual Hosting</title> @@ -668,6 +722,4 @@ </section> - - </manualpage>
|