Forum Moderators: bakedjake
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www.)?example.com.*$ [NC]
RewriteRule .(gif¦jpg)$ - [F]
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteRule \.(gif¦jpe?g¦png¦bmp)$ - [F]
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
[httpd.apache.org...] :)
There are a couple of mistakes and inefficiencies in that code, so let's stop it from spreading further. Try this:RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com [NC]
RewriteRule \.(gif¦jpe?g¦png¦bmp)$ - [F]This is just a clean-up; Function is unchanged except for adding the jpeg, png, and bmp filetypes.
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
It turns out example.com was the 3rd party unrelated website which was heavily linking to my images. Is there a way to stop more than one site doing it? Thanks to Jim and others for the feedback.
There are a couple of mistakes and inefficiencies in that code, so let's stop it from spreading further. Try this:RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com [NC]
RewriteRule \.(gif¦jpe?g¦png¦bmp)$ - [F]This is just a clean-up; Function is unchanged except for adding the jpeg, png, and bmp filetypes.
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Hi jdMorgan, Was wondering what the purpose of the (www\. is in this code since I 301 all my error code traffic to the non-www? Does that matter? Also, just to be certain about this code, should example.com in fact be my domain and not the domain I wish to block (as mcavic had stated)? Thanks to all.
Some ISPs --like Hughes Network (satellite)-- use proxy clients between the real client and your server. These proxy clients, located at the ISPs network operations center, are intended to compensate for the long-latency satellite signal travel time (22,300 miles X 4 / 186,000 mps = ~480 millisecond signal delay).
However, these proxy clients are not real smart, and don't follow HTTP redirects as a real client would. They request a page on behalf of the real client, then request all included objects (e.g. images, css, external JS files) referenced on that page, package up the whole mess, and send it up to the satellite and back down to the client. The client-side satellite software (in the satellite modem or installed on the client machine) then decompresses and un-bundles the package into the original page and all its components. Overall, this makes the link appear run faster.
However, if the vistor typed in your domain incorrectly, or clicked on an incorrect link (with www missing or present, whichever is 'wrong') then the satellite proxy client may have made all of those object requests with the incorrect www/no-www domain. His browser will have to retry all requests that got a 403-Forbidden response, and this will slow your page apparent page load time by at least an addition one-half second (and usually by a lot more).
Long story short, according to my log files showing satellite accesses, it's best to allow the non-canonical domain to access images, CSS, JS files, etc.. :)
Jim
"Canonical [google.com]" isn't some fancy tech term. It simply means "usual, customary, standard, basic, according to the rules, generally-accepted" and it is the site owner who gets to define the canonical domain for a site -- usually by 301-redirecting all non-canonical variants to the canonical domain.
Jim