Forum Moderators: phranque
I prevent hotlinking using htaccess file:
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]
RewriteRule \.(gif¦GIF¦jpg¦JPG¦bmp¦BMP¦swf)$ /hotlinking/banned.gif [L,NC]
I want to add mail.live.com to the allowed sites but there are many subdomains such as:
sn105w.snt105.mail.live.com
bl105w.blu105.mail.live.com
bl106w.blu106.mail.live.com
bl108w.blu108.mail.live.com
bl117w.blu117.mail.live.com
bl118w.blu118.mail.live.com
bl122w.blu122.mail.live.com
bl130w.blu130.mail.live.com
bl133w.blu133.mail.live.com
bl144w.blu144.mail.live.com
by113w.bay113.mail.live.com
by118w.bay118.mail.live.com
by119w.bay119.mail.live.com
by129w.bay129.mail.live.com
by130w.bay130.mail.live.com
by135w.bay135.mail.live.com
by139w.bay139.mail.live.com
by141w.bay141.mail.live.com
by143w.bay143.mail.live.com
co103w.col103.mail.live.com
co118w.col118.mail.live.com
Is is it possible to add a wildcard which contains all mail.live.com urls ?
Thanks
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]
Important: Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)+mail\.live\.com [NC]
Jim,
Could you possibly translate this for a dunce?
Many thanks.
Don
edited by wilderness
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]
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]
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