Forum Moderators: phranque

Message Too Old, No Replies

RewriteCond %{HTTP_REFERER} question

How to add more than one suffix to a domain?

         

Warmbells

6:10 pm on Jul 30, 2004 (gmt 0)

10+ Year Member



Hi,

I'm new to all this htaccess and have read a few tutorials but I can't seem to find how to check for different suffixes for a domain.

I have rules for Google images as follows
RewriteCond %{HTTP_REFERER}!^http://images.google.fr/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.at/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.de/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.nl/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.ca/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.se/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.pl/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.it/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.fi/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.sk/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.be/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.co.hu/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.com/.*$ [NC]

is there a way I could make this into a single RewriteCond?

Thanks

jdMorgan

7:32 pm on Jul 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Warmbells,

Welcome to WebmasterWorld [webmasterworld.com]!

An example for your first four countries (add as many as you like, though):


RewriteCond %{HTTP_REFERER} !^http://images\.google\.(fr¦at¦de¦nl)/ [NC]

or, simply use:

RewriteCond %{HTTP_REFERER} !^http://images\.google\.[a-z]{2}/ [NC]

to accept any two-letter country-code.

You don't need ".*$" on the end; leaving the pattern unanchored means the same thing in this case.

Note that posting on this board changes the vertical pipe character to a broken pipe "¦". You will need to change them back to solid pipe characters before use.

Check our forum charter for a few useful reference links.

Jim

Warmbells

7:56 pm on Jul 30, 2004 (gmt 0)

10+ Year Member



Thanks Jim for the help and the information, I'll take a look.

Warmbells