Syntax for .htaccess files


#1

hi folks-

in dealing with referrer spam, i’m trying to optimize my .htaccess file. couldn’t find an answer to this anywhere.

to deal with subdomains, can i use this syntax:

RewriteCond %{HTTP_REFERER} ^http://(www.)?.domain.com$ [NC,OR]

or do i need to have the entire subdomain listed, like so:

RewriteCond %{HTTP_REFERER} ^http://(www.)?subdomain.domain.com*$ [NC,OR]

couldn’t find this anywhere (weirdly). thanks!

yours,

/pk


#2

Don’t forget to put a \ in front of periods you need to match on, and I’m not sure you are using the asterisk correctly.

Try ^http://.*.domain.com

This should match any referrers that start with ‘http://’, then have a string of characters (or none), then ‘.domain.com’

Regular expression syntax can be found at http://www.perl.com/doc/manual/html/pod/perlre.html

And there is also http://httpd.apache.org/docs/misc/rewriteguide.html

:cool: Perl / MySQL / HTML+CSS


#3

right on. thanks.

yours,

/pk