<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Peter's Blog - Nodes for mod_rewrite</title>
    <link>http://www.petersblog.org/</link>
    <description>Nodes containing the tag mod_rewrite</description>
    <item>
      <title>mod_rewrite</title>
      <link>http://www.petersblog.org/node/view/815</link>
      <description>&lt;p&gt;
&lt;a href=&quot;http://httpd.apache.org/docs/mod/mod_rewrite.html&quot;&gt;mod_rewrite&lt;/a&gt; is a module for the &lt;a href=&quot;tags/apache&quot;&gt;Apache&lt;/a&gt; web server that allows web requests to be rewritten according to rules listed in a .htaccess file. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href=&quot;/tag/htaccess&quot;&gt;htaccess&lt;/a&gt; &lt;a href=&quot;/tag/mod_rewrite&quot;&gt;mod_rewrite&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/815</guid>
      <pubDate>Wed, 25 May 2005 20:36:05 +0100</pubDate>
      <category domain="http://www.technorati.com/tag">htaccess</category>
      <category domain="http://www.technorati.com/tag">mod_rewrite</category>
    </item>
    <item>
      <title>Drupal Search Problem</title>
      <link>http://www.petersblog.org/node/view/814</link>
      <description>&lt;p&gt;
Found a problem searching &lt;a href=&quot;tags/drupal&quot;&gt;Drupal&lt;/a&gt; sites that use 'clean urls'. It even happens on the main &lt;a href=&quot;http://www.drupal.org&quot;&gt;Drupal site&lt;/a&gt;. Just do a search for 'die/die' and you get the following error: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;Not Found
The requested URL /search/node/die/die was not found on this server.

Apache/1.3.33 Server at drupal.org Port 80
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
Clean urls requires a mod_rewrite hack to turn 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;http://www.drupal.org/search/node/die/die
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
into 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;http://www.drupal.org/index.php?q=search/node/die/die
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
but this is not working properly. If you try the second form above in a browser then it works, the search is done but mod_rewrite does not seem to correctly munge it. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href=&quot;/tag/apache&quot;&gt;apache&lt;/a&gt; &lt;a href=&quot;/tag/drupal&quot;&gt;drupal&lt;/a&gt; &lt;a href=&quot;/tag/mod_rewrite&quot;&gt;mod_rewrite&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/814</guid>
      <pubDate>Wed, 25 May 2005 20:03:06 +0100</pubDate>
      <category domain="http://www.technorati.com/tag">apache</category>
      <category domain="http://www.technorati.com/tag">drupal</category>
      <category domain="http://www.technorati.com/tag">mod_rewrite</category>
    </item>
    <item>
      <title>Trackback spam hitting Innocent Bystanders</title>
      <link>http://www.petersblog.org/node/view/718</link>
      <description>&lt;p&gt;
My server is being hit by attempts to submit trackback spam which is particulary annoying as I don't have trackback. By default &lt;a href=&quot;http://www.drupal.org&quot;&gt;Drupal&lt;/a&gt; formats up a full web page with a fancy 'page not found' line for a 404 error (page not found). To save server time and bandwidth, I've put this at the top of my .htaccess file: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;ErrorDocument 403 /fail.html
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
Fail.html is a minimal html file containing just the string '403 error'. Should be little enough load for the server: 
&lt;/p&gt;
&lt;pre class=&quot;lazy&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;MetaTag&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Error&lt;span class=&quot;MetaTag&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;MetaTag&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;MetaTag&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
Error 403
&lt;span class=&quot;MetaTag&quot;&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;MetaTag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;
This is added to the mod_rewrite rules: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;#
# Reject any attempt to submit trackback spam
#
RewriteRule ^(.*)trackback(.*)$ - [F]
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
any url with 'trackback' in it is rejected with the minimal 403 error. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href=&quot;/tag/drupal&quot;&gt;drupal&lt;/a&gt; &lt;a href=&quot;/tag/htaccess&quot;&gt;htaccess&lt;/a&gt; &lt;a href=&quot;/tag/mod_rewrite&quot;&gt;mod_rewrite&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/718</guid>
      <pubDate>Mon, 21 Feb 2005 14:21:25 +0000</pubDate>
      <category domain="http://www.technorati.com/tag">drupal</category>
      <category domain="http://www.technorati.com/tag">htaccess</category>
      <category domain="http://www.technorati.com/tag">mod_rewrite</category>
    </item>
    <item>
      <title>Mod_rewrite Referrer (aka Referer) Spam Blocking</title>
      <link>http://www.petersblog.org/node/view/691</link>
      <description>&lt;p&gt;
This is a python script to test out .htaccess mod_rewrite rules to block referrer spam. I just hate the idea of these parasites sucking my bandwidth. 
&lt;/p&gt;
&lt;pre class=&quot;lazy&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Test .htaccess&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;import&lt;/span&gt; httplib
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;import&lt;/span&gt; urllib2
&lt;span class=&quot;line-numbers&quot;&gt;   6 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;   7 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   8 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Site to test&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   9 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  10 &lt;/span&gt; strSite &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.petersblog.org&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  11 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;  12 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  13 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Bad referrers: should fail&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  14 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  15 &lt;/span&gt; strBadReferrers &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; [
&lt;span class=&quot;line-numbers&quot;&gt;  16 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.blah.info&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  17 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://blah.info&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  18 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://any.blah.info&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  19 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.blah.info/&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  20 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.blah.info/this/should/still/fail&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  21 &lt;/span&gt; ]
&lt;span class=&quot;line-numbers&quot;&gt;  22 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;  23 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  24 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Good referrers: should pass&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  25 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  26 &lt;/span&gt; strGoodReferrers &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; [
&lt;span class=&quot;line-numbers&quot;&gt;  27 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.google.com&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  28 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.google.com/search?q=tecrep-inc.net&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  29 &lt;/span&gt;     strSite,                    &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; allow internal referrer in&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  30 &lt;/span&gt;     strSite &lt;span class=&quot;Keyword&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;/node/123&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
&lt;span class=&quot;line-numbers&quot;&gt;  31 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;                          &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; no referrer&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  32 &lt;/span&gt; ]
&lt;span class=&quot;line-numbers&quot;&gt;  33 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;  34 &lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;TestReferrer&lt;/span&gt;( &lt;span class=&quot;Variable&quot;&gt;strReferrer&lt;/span&gt;):
&lt;span class=&quot;line-numbers&quot;&gt;  35 &lt;/span&gt;     &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Test whether a referrer is allowed in: True if so&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  36 &lt;/span&gt;     &lt;span class=&quot;Keyword&quot;&gt;try&lt;/span&gt;:
&lt;span class=&quot;line-numbers&quot;&gt;  37 &lt;/span&gt;         request &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;MetaFunctionCallPy&quot;&gt;urllib2.Request&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;strSite&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  38 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; strReferrer &lt;span class=&quot;Keyword&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;:
&lt;span class=&quot;line-numbers&quot;&gt;  39 &lt;/span&gt;             &lt;span class=&quot;MetaFunctionCallPy&quot;&gt;request.add_header&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;referer&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, strReferrer&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  40 &lt;/span&gt;         opener &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;MetaFunctionCallPy&quot;&gt;urllib2.build_opener&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  41 &lt;/span&gt;         data &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;MetaFunctionCallPy&quot;&gt;opener.open&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;read&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  42 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;True&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  43 &lt;/span&gt;     &lt;span class=&quot;Keyword&quot;&gt;except&lt;/span&gt;(urllib2.HTTPError):
&lt;span class=&quot;line-numbers&quot;&gt;  44 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;False&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  45 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;  46 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  47 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Test bad referrers.&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  48 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  49 &lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; strReferrer &lt;span class=&quot;Keyword&quot;&gt;in&lt;/span&gt; strBadReferrers:
&lt;span class=&quot;line-numbers&quot;&gt;  50 &lt;/span&gt;     &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;MetaFunctionCallPy&quot;&gt;TestReferrer&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt; strReferrer&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;:
&lt;span class=&quot;line-numbers&quot;&gt;  51 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Failed: allowed &lt;span class=&quot;StringInterpolation&quot;&gt;%s&lt;/span&gt; in&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; strReferrer
&lt;span class=&quot;line-numbers&quot;&gt;  52 &lt;/span&gt;     &lt;span class=&quot;Keyword&quot;&gt;else&lt;/span&gt;:
&lt;span class=&quot;line-numbers&quot;&gt;  53 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Passed: didn't allow &lt;span class=&quot;StringInterpolation&quot;&gt;%s&lt;/span&gt; in&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; strReferrer
&lt;span class=&quot;line-numbers&quot;&gt;  54 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;  55 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  56 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Test good referrers.&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  57 &lt;/span&gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  58 &lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; strReferrer &lt;span class=&quot;Keyword&quot;&gt;in&lt;/span&gt; strGoodReferrers:
&lt;span class=&quot;line-numbers&quot;&gt;  59 &lt;/span&gt;     &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;MetaFunctionCallPy&quot;&gt;TestReferrer&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt; strReferrer&lt;/span&gt;&lt;span class=&quot;MetaFunctionCallPy&quot;&gt;)&lt;/span&gt;&lt;/span&gt;:
&lt;span class=&quot;line-numbers&quot;&gt;  60 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Passed: allowed &lt;span class=&quot;StringInterpolation&quot;&gt;%s&lt;/span&gt; in&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; strReferrer
&lt;span class=&quot;line-numbers&quot;&gt;  61 &lt;/span&gt;     &lt;span class=&quot;Keyword&quot;&gt;else&lt;/span&gt;:
&lt;span class=&quot;line-numbers&quot;&gt;  62 &lt;/span&gt;         &lt;span class=&quot;Keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Failed: didn't allow &lt;span class=&quot;StringInterpolation&quot;&gt;%s&lt;/span&gt; in&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; strReferrer
&lt;div class=&quot;linetoggle&quot; onclick=&quot;$$('.line-numbers').invoke( 'toggle');&quot;&gt;Toggle Line Numbers&lt;/div&gt;&lt;/pre&gt;
&lt;p&gt;
I find the following format for mod_rewrite referrer blocking to be effective. 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;RewriteCond %{HTTP_REFERER} ^http://[^/]*blah.net($|/.*$) [OR]
RewriteCond %{HTTP_REFERER} ^http://[^/]*blah.com($|/.*$) [OR]
RewriteCond %{HTTP_REFERER} ^http://[^/]*blahblah.org($|/.*$) [NC]
RewriteRule ^.* - [F]
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
A good source for a list of sites to block can be found in any comment spam that happens to get through. Note that one rule such as: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;RewriteCond %{HTTP_REFERER} ^http://[^/]*blah.com($|/.*$) [NC]
RewriteRule ^.* - [F]
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
will catch all the following permutations: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;* http://www.blah.com/
* http://www.foo.blah.com/
* http://www.foo.bar.blah.com/
* http://www.foo.bar.blah.com/still/not/allowed
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
Note: I've seen referrer spelt 'referer' a lot and it is spelt this way in the .htaccess rules but google define assures me I'm spelling it right: referer sounds to me more like a smoker of certain narcotic substances. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href=&quot;/tag/google&quot;&gt;google&lt;/a&gt; &lt;a href=&quot;/tag/htaccess&quot;&gt;htaccess&lt;/a&gt; &lt;a href=&quot;/tag/mod_rewrite&quot;&gt;mod_rewrite&lt;/a&gt; &lt;a href=&quot;/tag/python&quot;&gt;python&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/691</guid>
      <pubDate>Fri, 28 Jan 2005 09:20:43 +0000</pubDate>
      <category domain="http://www.technorati.com/tag">google</category>
      <category domain="http://www.technorati.com/tag">htaccess</category>
      <category domain="http://www.technorati.com/tag">mod_rewrite</category>
      <category domain="http://www.technorati.com/tag">python</category>
    </item>
    <item>
      <title>Robots.txt</title>
      <link>http://www.petersblog.org/node/view/434</link>
      <description>&lt;p&gt;
My logs show attempts by GoogleBot et al to access a robots.txt file so I've decided not to disappoint them any more and have provided them with this: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;User-agent: *
Disallow:
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
This is telling them to scan away, I'm open. 
&lt;/p&gt;
&lt;p&gt;
Googling for robots.txt it is interesting to see the fifth entry is for http://www.whitehouse.gov/robots.txt i.e. the white house's robots.txt file. It seems to do a lot of disallowing. I hope this isn't going to be interpreted as political commentry. 
&lt;/p&gt;
&lt;p&gt;
I didn't need a mod_rewrite rule to get this working, it Just Worked. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href=&quot;/tag/mod_rewrite&quot;&gt;mod_rewrite&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/434</guid>
      <pubDate>Tue, 14 Sep 2004 15:11:38 +0100</pubDate>
      <category domain="http://www.technorati.com/tag">mod_rewrite</category>
    </item>
    <item>
      <title>Googled</title>
      <link>http://www.petersblog.org/node/view/430</link>
      <description>&lt;p&gt;
I noticed in my Drupal logs that google is looking for a file called rss.xml on my site: 
&lt;/p&gt;
&lt;div class=&quot;verbatim-block&quot;&gt;&lt;pre&gt;09/10/2004 - 13:23  404 error: 'rss.xml' not found	Anonymous
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
I am eager to keep google happy but how to create such a file? I had a brainwave and added a mod_rewrite rule to my .htaccess file: 
&lt;/p&gt;
&lt;p&gt;
  RewriteRule rss.xml blog/feed/1 
&lt;/p&gt;
&lt;p&gt;
So any attempts to access rss.xml trigger the link that my RSS buttons point to. Note that I have 'Clean Urls' turned on. 
&lt;/p&gt;
&lt;p&gt;
Come back google, I'm waiting for you! 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href=&quot;/tag/blog&quot;&gt;blog&lt;/a&gt; &lt;a href=&quot;/tag/drupal&quot;&gt;drupal&lt;/a&gt; &lt;a href=&quot;/tag/google&quot;&gt;google&lt;/a&gt; &lt;a href=&quot;/tag/htaccess&quot;&gt;htaccess&lt;/a&gt; &lt;a href=&quot;/tag/mod_rewrite&quot;&gt;mod_rewrite&lt;/a&gt; &lt;a href=&quot;/tag/rss&quot;&gt;rss&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/430</guid>
      <pubDate>Fri, 10 Sep 2004 12:39:01 +0100</pubDate>
      <category domain="http://www.technorati.com/tag">blog</category>
      <category domain="http://www.technorati.com/tag">drupal</category>
      <category domain="http://www.technorati.com/tag">google</category>
      <category domain="http://www.technorati.com/tag">htaccess</category>
      <category domain="http://www.technorati.com/tag">mod_rewrite</category>
      <category domain="http://www.technorati.com/tag">rss</category>
    </item>
  </channel>
</rss>
