From: Rich Bowen Date: Mon, 16 Nov 2009 11:17:54 +0000 (+0000) Subject: Not sure this is actually a useful recipe, but it belongs in the access X-Git-Tag: 2.3.4~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=acb8dce5e2fc75cc00e8e29ac949ddf356fbc796;p=thirdparty%2Fapache%2Fhttpd.git Not sure this is actually a useful recipe, but it belongs in the access file. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@880707 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/access.html.en b/docs/manual/rewrite/access.html.en index 12ee3d436e6..6f0dc6725df 100644 --- a/docs/manual/rewrite/access.html.en +++ b/docs/manual/rewrite/access.html.en @@ -38,6 +38,7 @@ configuration.

See also

top
@@ -244,6 +245,55 @@ bsdti1.sdm.de - +
top
+
+

Referer-based Deflector

+ + + +
+
Description:
+ +
+

Redirect requests based on the Referer from which the request + came, with different targets per Referer.

+
+ +
Solution:
+ +
+

The following ruleset uses a map file to associate each Referer + with a redirection target.

+ +
+RewriteMap  deflector txt:/path/to/deflector.map
+
+RewriteCond %{HTTP_REFERER} !=""
+RewriteCond ${deflector:%{HTTP_REFERER}} =-
+RewriteRule ^ %{HTTP_REFERER} [R,L]
+
+RewriteCond %{HTTP_REFERER} !=""
+RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
+RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]
+
+ +

The map file lists redirection targets for each referer, or, if + we just wish to redirect back to where they came from, a "-" is + placed in the map:

+ +
+##
+##  deflector.map
+##
+
+http://www.badguys.com/bad/index.html    -
+http://www.badguys.com/bad/index2.html   -
+http://www.badguys.com/bad/index3.html   http://somewhere.com/
+
+ +
+
+

Available Languages:  en 

diff --git a/docs/manual/rewrite/access.xml b/docs/manual/rewrite/access.xml index 4b23440e98b..7a87eb5387d 100644 --- a/docs/manual/rewrite/access.xml +++ b/docs/manual/rewrite/access.xml @@ -252,4 +252,53 @@ bsdti1.sdm.de - +
+ + Referer-based Deflector + +
+
Description:
+ +
+

Redirect requests based on the Referer from which the request + came, with different targets per Referer.

+
+ +
Solution:
+ +
+

The following ruleset uses a map file to associate each Referer + with a redirection target.

+ +
+RewriteMap  deflector txt:/path/to/deflector.map
+
+RewriteCond %{HTTP_REFERER} !=""
+RewriteCond ${deflector:%{HTTP_REFERER}} =-
+RewriteRule ^ %{HTTP_REFERER} [R,L]
+
+RewriteCond %{HTTP_REFERER} !=""
+RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
+RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]
+
+ +

The map file lists redirection targets for each referer, or, if + we just wish to redirect back to where they came from, a "-" is + placed in the map:

+ +
+##
+##  deflector.map
+##
+
+http://www.badguys.com/bad/index.html    -
+http://www.badguys.com/bad/index2.html   -
+http://www.badguys.com/bad/index3.html   http://somewhere.com/
+
+ +
+
+ +
+ diff --git a/docs/manual/rewrite/rewrite_guide.html.en b/docs/manual/rewrite/rewrite_guide.html.en index 86d934dc359..73095f0a42d 100644 --- a/docs/manual/rewrite/rewrite_guide.html.en +++ b/docs/manual/rewrite/rewrite_guide.html.en @@ -52,7 +52,6 @@
  • Retrieve Missing Data from Intranet
  • New MIME-type, New Service
  • Mass Virtual Hosting
  • -
  • Referer-based Deflector
  • See also

    top
    -
    -

    Referer-based Deflector

    - - - -
    -
    Description:
    - -
    -

    How can we program a flexible URL Deflector which acts - on the "Referer" HTTP header and can be configured with as - many referring pages as we like?

    -
    - -
    Solution:
    - -
    -

    Use the following really tricky ruleset...

    - -
    -RewriteMap  deflector txt:/path/to/deflector.map
    -
    -RewriteCond %{HTTP_REFERER} !=""
    -RewriteCond ${deflector:%{HTTP_REFERER}} ^-$
    -RewriteRule ^.* %{HTTP_REFERER} [R,L]
    -
    -RewriteCond %{HTTP_REFERER} !=""
    -RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
    -RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]
    -
    - -

    ... in conjunction with a corresponding rewrite - map:

    - -
    -##
    -##  deflector.map
    -##
    -
    -http://www.badguys.com/bad/index.html    -
    -http://www.badguys.com/bad/index2.html   -
    -http://www.badguys.com/bad/index3.html   http://somewhere.com/
    -
    - -

    This automatically redirects the request back to the - referring page (when "-" is used as the value - in the map) or to a specific URL (when an URL is specified - in the map as the second argument).

    -
    -
    -

    Available Languages:  en  | diff --git a/docs/manual/rewrite/rewrite_guide.xml b/docs/manual/rewrite/rewrite_guide.xml index c8ec04a2d95..3fb19eabec5 100644 --- a/docs/manual/rewrite/rewrite_guide.xml +++ b/docs/manual/rewrite/rewrite_guide.xml @@ -591,58 +591,6 @@ RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}] -

    - - Referer-based Deflector - -
    -
    Description:
    - -
    -

    How can we program a flexible URL Deflector which acts - on the "Referer" HTTP header and can be configured with as - many referring pages as we like?

    -
    - -
    Solution:
    - -
    -

    Use the following really tricky ruleset...

    - -
    -RewriteMap  deflector txt:/path/to/deflector.map
    -
    -RewriteCond %{HTTP_REFERER} !=""
    -RewriteCond ${deflector:%{HTTP_REFERER}} ^-$
    -RewriteRule ^.* %{HTTP_REFERER} [R,L]
    -
    -RewriteCond %{HTTP_REFERER} !=""
    -RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
    -RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]
    -
    - -

    ... in conjunction with a corresponding rewrite - map:

    - -
    -##
    -##  deflector.map
    -##
    -
    -http://www.badguys.com/bad/index.html    -
    -http://www.badguys.com/bad/index2.html   -
    -http://www.badguys.com/bad/index3.html   http://somewhere.com/
    -
    - -

    This automatically redirects the request back to the - referring page (when "-" is used as the value - in the map) or to a specific URL (when an URL is specified - in the map as the second argument).

    -
    -
    - -
    -