Forum Moderators: phranque

Message Too Old, No Replies

Rewrite Request URI not working

         

guillermo5000

6:06 am on Mar 29, 2007 (gmt 0)

10+ Year Member



I have forum that is under attack by spammers. The bots are posting with a common URI that I'm hoping to block.

If I can block any URI that contains "coppa_pass=1", an adult verification system that my board does not use, then I can greatly reduce the spam to my forum.

The entire request is:
[#*$!#*$!.org...]

Below is my feeble attempt at blocking "coppa", but it doesn't seem to work.

RewriteCond %{REQUEST_URI} ^/*coppa [NC]
RewriteRule .* - [R=301,L]

Any advice is greatly appriciated!

phranque

6:53 am on Mar 29, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



try this:
RewriteCond %{REQUEST_URI} coppa [NC]

guillermo5000

8:53 am on Mar 29, 2007 (gmt 0)

10+ Year Member



Thank you, but that doesn't seem to work either. :(

phranque

12:20 pm on Mar 29, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



do you have RewriteEngine on and all that?

jdMorgan

2:10 pm on Mar 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The main problem is that if the rule matches, you're redirecting to the original URL anyway, so executing the rule doesn't actually do anything. Instead of a redirect, you need to return a 403-Forbidden response using [F] -- or perhaps redirect to somewhere else (not recommended, as it is bad 'Web citizenship').

Assuming your code goes into the /cgi-bin/.htaccess file, you could use:


RewriteCond %{QUERY_STRING} coppa [NC]
RewriteRule ^ib3/ikonboard\.cgi$ - [F]

The code *will* need to change, depending on where you put it. If /cgi-bin is an aliased directory (and this is quite common on shared hosting), then you cannot (easily) affect any access to that directory using a .htaccess file in your Web root -- The .htaccess code almost always has to go into the /cgi-bin directory itself.

Jim

guillermo5000

5:40 pm on Mar 29, 2007 (gmt 0)

10+ Year Member



I've tried that code, it does not work either. I've also tried JP's first line with a redirect to one of my other sites with no success.

You are correct, my .htaccess is in the cgi-bin and I am on a shared host server.

Are you saying it is not possable to do what I want on a shared server? Thanks all!

P.S. rewrites are ON

guillermo5000

5:41 pm on Mar 29, 2007 (gmt 0)

10+ Year Member



I'm sorry it's JD. :}

guillermo5000

5:52 pm on Mar 29, 2007 (gmt 0)

10+ Year Member



Aha! I've made it work! (with your help) Using QUERY_STRING and then redirecting to another site.

RewriteCond %{QUERY_STRING} coppa [NC]
RewriteRule ^.*$ [MYotherSITE.org...] [R=301,L]

This code also works, returning a 403 error:

RewriteCond %{QUERY_STRING} coppa [NC]
RewriteRule .* - [F]

Clearly I need to read up on QUERY_STRING, I've never uses that before. I assummed that anything in the page address is URI.

Thank you all for help.

jdMorgan

10:58 pm on Mar 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, except that a query string *is not* part of a page address (URL); It is data attached to a URL to be passed *to* that page address. That is why it is handled separately in the server variables. :)

Jim