Jump to content

.htaccess Rewritemap

Recommended Posts

I would like to use a RewriteMap to bounce known referrer spammers off of my site before they have a chance to waste my bandwidth.


I found a tutorial at http://httpd.apache.org/docs/misc/rewriteguide.html (Referrer-Based Deflector) that I'd like to use, and I am going to write a php script to generate the map out of a database as needed (whenever a new item is added to the db, that is.)


However, when I set up a test at http://www.isaacschlueter.com/tests/rewrite_map_tests/ I'm just getting an HTTP 500 error. My errorlog shows:

>[Fri Jun 17 14:06:46 2005] [alert] [client] 
/home/My_User_Name/public_html/tests/rewrite_map_tests/.htaccess: RewriteMap not allowed here


First question: Are we allowed to use RewriteMap directives at all, or am I wasting my time?


Second question: Is there some part of my site where it'd be allowed, but perhaps it's just not allowed in /tests/rewrite_map_tests?



For reference, here's what it says in my .htaccess at the moment:

>RewriteEngine On

RewriteMap  spamdeflector txt:/home/My_User_Name/public_html/tests/rewrite_map_tests/spammerlist.map

RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${spamdeflector:%{HTTP_REFERER}} ^-$
RewriteRule ^.* %{HTTP_REFERER} [R,L]

RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${spamdeflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^.* ${spamdeflector:%{HTTP_REFERER}} [R,L]

I've tried accessing it with the relative path (just spammerlist.map or /spammerlist.map instead of the full path) but that didn't work any better.


Here's what's in spammerlist.map

>http://isaac/	-
http://localhost/ -

(Keep in mind, this is just a test. This should bounce all requests from my local machine, and I have an index.html which links to it, running on my local box.)


Any ideas?

Edited by IsaacSchlueter
Link to comment
Share on other sites

Ah, well that answers that.


I don't suppose that there's any way that I can access my httpd.conf file? I would expect that would be doubtful, since I believe I'm on a shared server and that would affect everyone, woudln't it?


What about if I had dedicated server hosting? Would I be able to access the httpd.conf file then?

Link to comment
Share on other sites

On a shared server, there is only one install of Apache, with one configuration file, that everyone shares. Changes made to the common Apache config file can directly and indirectly affect all other users on that server.


With a dedicated server, yes, you would be able to configure the web server however you wanted.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...