Forum Moderators: phranque

Message Too Old, No Replies

Forbiding access through HTTP_HOST

Problem with regexp or with directive syntax

         

Marino

8:30 am on Jul 23, 2005 (gmt 0)

10+ Year Member



Hello,

I'm trying to forbid access to a domain along with all its subdomains using:

RewriteCond %{HTTP_HOST} ^(([a-z0-9\-]+\.)*somesite\.com)$ [NC]
RewriteRule ^(.*)$ [%1...] [R=301,L]

It should redirect the referer -some spammer- towards itself, but it does not work... No effect at all.

"back-references %N to the last matched RewriteCond pattern" says the Apache 2 documentation. Or did I misunderstood something?

Thanks for your help.

Marino

8:36 am on Jul 23, 2005 (gmt 0)

10+ Year Member



And I forgot : this code is in my .htaccess file, of course.

Longhaired Genius

10:06 am on Jul 23, 2005 (gmt 0)

10+ Year Member



If I understand you correctly, your code is more complex than it needs to be.

Your rewrite condition only needs to be comprehensive enough to be sufficiently exclusive.

This will forbid all links from a domain:

# begin .htaccess code

Options +FollowSymlinks

RewriteEngine on

RewriteCond %{HTTP_REFERER} somesite
RewriteRule .* - [F,L]

# end .htaccess code

Is that what you're trying to do?