From: Rich Bowen Date: Sat, 21 Nov 2009 00:07:26 +0000 (+0000) Subject: Adds a 'rewrite everything' or 'fallback resource' rule. X-Git-Tag: 2.3.4~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba4f21e6d6917f9e51de3e04495ccd727dfaaa15;p=apache Adds a 'rewrite everything' or 'fallback resource' rule. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@882797 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index 48981ace51..6ef1e53fca 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -46,6 +46,7 @@ configuration.
  • Canonical URLs
  • Virtual Hosts Per User
  • Moved DocumentRoot
  • +
  • Fallback Resource
  • Mass Virtual Hosting
  • Proxying Content with mod_rewrite
  • See also

    @@ -589,6 +590,55 @@ rather than rewriting URLs.

    +
    top
    +
    +

    Fallback Resource

    + + +
    +
    Description:
    +
    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.
    + +
    Solution:
    +
    +

    As of version 2.4, you should use the FallbackResource directive for this:

    + +
    +<Directory /var/www/my_blog>
    +  FallbackResource index.php
    +</Directory>
    +
    + +

    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:

    + +
    +<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>
    +
    + +

    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:

    + +
    +  RewriteRule (.*) index.php?$1 [PT,QSA]
    +
    + +

    Note that these rulesets can be uses in a .htaccess +file, as well as in a <Directory> block.

    + +
    + +
    +
    top

    Mass Virtual Hosting

    diff --git a/docs/manual/rewrite/remapping.xml b/docs/manual/rewrite/remapping.xml index 142ea6dd06..8e87235019 100644 --- a/docs/manual/rewrite/remapping.xml +++ b/docs/manual/rewrite/remapping.xml @@ -159,8 +159,6 @@ Redirect /docs/ http://new.example.com/docs/ - -
    From Static to Dynamic @@ -593,6 +591,62 @@ rather than rewriting URLs.

    +
    +Fallback Resource + +
    +
    Description:
    +
    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.
    + +
    Solution:
    +
    +

    As of version 2.4, you should use the FallbackResource directive for this:

    + + +
    +<Directory /var/www/my_blog>
    +  FallbackResource index.php
    +</Directory>
    +
    +
    + +

    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:

    + + +
    +<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>
    +
    +
    + +

    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:

    + + +
    +  RewriteRule (.*) index.php?$1 [PT,QSA]
    +
    +
    + +

    Note that these rulesets can be uses in a .htaccess +file, as well as in a <Directory> block.

    + +
    + +
    + +
    +
    Mass Virtual Hosting @@ -668,6 +722,4 @@ ProxyPassReverse / http://old.example.com/
    - -