wilderness

msg:3840810 | 2:01 am on Feb 3, 2009 (gmt 0) |
Jim or another will need to clean this up (definitely not my forte) [a-z]{2}+[0-9]{3}+w\.[a-z]{3}+[0-9]{3}+\.mail\.live.com See forum charter and "Regular Expressions Tutorial" near page top. There are many examples of these wildcards in numerous threads.
|
jdMorgan

msg:3840833 | 3:06 am on Feb 3, 2009 (gmt 0) |
RewriteEngine on # RewriteCond %{HTTP_REFERER} . RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite1\.com [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite2\.com [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite3\.com [NC] RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)+mail\.live\.com [NC] RewriteCond %{REQUEST_URI} !^/hotlinking/banned\.gif$ RewriteRule \.(gif¦jpg¦bmp¦swf)$ /hotlinking/banned.gif [[b]NC[/b],L]
That new rewriteCond should do it. I also cleaned up several inefficiencies in other parts of the code. These clean-ups will not change the way the code works at all, except that it will run faster. For example, there was no need to include case-variations in the image-filetype pattern, because you already had the [NC] flag on the RewriteRule, making the pattern-match case-insensitive. Also ".*$" is a waste of time; Nothing changes at all if you just leave it off. All literal periods in regex patterns should be escaped as shown, unless they are part of an alternate [group] (as also shown). Important: Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters. Jim
|
wilderness

msg:3840841 | 3:26 am on Feb 3, 2009 (gmt 0) |
| RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)+mail\.live\.com [NC] |
| Jim, Could you possibly translate this for a dunce? Many thanks. Don edited by wilderness ([^.]+\.)+mail Begins with AND Matches any one character Matches the preceding element one or more times escape DOT prior to bay This closing confuses me? Matches the entire previously closed statement one or more times? I was following my first three explanations and somehow became lost in the "squall" ;) [edited by: wilderness at 3:35 am (utc) on Feb. 3, 2009]
|
jdMorgan

msg:3840849 | 3:35 am on Feb 3, 2009 (gmt 0) |
"([^.]+\.)+" means "One or more instances of (one or more characters not a period, followed by a period)." In other words "one or more subdomains". Jim [edit] Within an alternate character [group], the escaping rules change and "^" means NOT if it is the first character in the [group]. [/edit] [edited by: jdMorgan at 3:37 am (utc) on Feb. 3, 2009]
|
wilderness

msg:3840853 | 3:49 am on Feb 3, 2009 (gmt 0) |
| "^" means NOT if it is the first character |
| Jim, My apologies. Is this applied (in this instance) to differentiate between the 2nd or 3rd repeated instances of the different character sets?
|
jdMorgan

msg:3840865 | 4:24 am on Feb 3, 2009 (gmt 0) |
No, "([^.]+\.)+" just means "Match characters as long as they are NOT a period. Then require a period. Do the preceding one or more times." I am very fond of negative-match patterns, because they are often the most efficient way to parse out a string. For example, in a URL-path, slashes are used to separate the "directory levels". So as in the example here, where periods are used to separate subdomain (and sub-sub-domain) levels, you can use "([^/]+/)+" to say, "match one or more directory levels." Jim Jim
|
g1smd

msg:3841005 | 9:49 am on Feb 3, 2009 (gmt 0) |
It took me a while to understand the logic in that pattern, but I now find myself using it all the time.
|
rashe18

msg:3841293 | 4:31 pm on Feb 3, 2009 (gmt 0) |
Thanks all. Thanks jdMorgan.
|
|