webmastering info manual



Building your website ::
Building Promoting  Profiting  Tools  Services  News  Contact

Apache Modules


The Apache module mod_rewrite is a is a powerful (although complex) method to do URL manipulations. Even Apache gurus discover new cases where mod_rewrite can be used from time to time.

Deflecting users based on referer(HTTP header)::

Use the following 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).

Blocking Inline Images::
This is used to prevent cross linking of your images.

Suppose we want to protect graphics on webmastering.info, we use

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.webmastering.info/.*$ [NC]
RewriteRule .*\.gif$ - [F]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !.*/foo-with-gif\.html$
RewriteRule ^inlined-in-foo\.gif$ - [F]

Additional resources


Our Services


Copyright © 2001-2003 webmastering.info All Rights Reserved.