The code works fine , however I do custom graphics and css for a fantasy football hosting community, and they have 1000’s of sites on several servers, each site has a unique url , however I’m unable to figure out how to block certain sites where some users are duplicating and hotlinking my images and css
You notice many sites using the same server aka www.30 , while each site has a unique league id aka 18128 or 43896
Without blocking all images on any single server , can i use .htaccess to block to full url posted above
Yes, but WHY limit yourself to the 2012/home/74107 script/directory? I’d leave that off as well as the trailing slash after the domain AND the subdomain!
As you can see, I had second thoughts about requiring a subdomain at all (including www) so I deleted the \. before the domains in question. Better to whack them all!
If qX4w7.gif is in your DocumentRoot, I’d eliminate your absolute redirection (http://{domain}) and make that rule:
Please note that, with regex, you can match anything in the string without specifying the start or end anchors, i.e., in this last RewriteRule, \.({list of image file extensions})$ must contain a dot character, one of your extensions and then end ($ is the end anchor). You simply do not care about anything before the dot character so don’t even bother to address it with your .* which is meaningless.
The purpose i need this to serve is in fact to prohibit hotlinking from certain subdirectories on that domain , while I do allow hotlinking from the same domain with other sub directories , so i need something that will work in this case
for example here are 3 URLs all within the same domain , i want the ones ending in 18128 and 43896 to not be able to hotlink, while the other to be permitted
Thanks DK but this isn’t blocking all the pages within that league id , only the home page , it seems every page has a unique url for instance…these are all urls to the same league and using the above code will only block the “home” page while allowing images on the other pages. I can’t block the entire server like www30.myfantasyleague.com , or other sites i that have my authorization to use the css and images will be blocked too. So maybe what i wanted to accomplish isn’t even possible…damn it ! Perhaps if you were to give me a image from your server I can load onto the site, someone may be able to try to do this, but i’m not educated enough on this to figure it out myself.
The problem is with your “Specificity,” the specification of what you’re trying to block (and what you’re trying to allow). So long as you don’t use the end anchor on your {HTTP_REFERER} regex, you should be able to block all the linkages you want to block.
Look at it from a different angle: You’ve given specific permission to some users so list them and block everyone else! That’s probably a simpler thing to do.
The ? is the demarcation between the URI and the query string but it should be picked up by the {HTTP_REFERER}. Should is the operative word here, though. If you’re allowing 2012 across the board, why not just terminate the {HTTP_REFERER} after 2012/ and allow all 2012’s pages?
It would be simple if I was allowing 2012 across the board , but there are 1000’s of 2012 leagues and I only allow perhaps 50 of them , so i have to carry out the full URL
The way that company has set up their site using java to pull the league id is crazy , i don’t know if its’ even possible to block/allow a single site
I think I’ve tried just about everything and nothing is working. I don’t know if its possible given the nature of how myfantasyleague.com set up their leagues on each server. What would be great is to have some script I could embed in the header of each individual site that authorizes the image/css use by checking my servers directory of that given league by a unique code/php script or something , aside of that I don’t think I can achieve what I need.
I’ve tested locally and the $_SERVER[‘HTTP_REFERER’] value was reported as http://test/test1.html?key=value&key2=value2 so your testing of {HTTP_REFERER} was correct - it does include the protocol, domain, URI and query string. Therefore, specify away with all (test for not AND not AND …). If you’re going to post a “pirated from” image, excude it in a final RewriteCond as another NOT against the {REQUEST_URI}.
dk , that may as well been in russian lol , i have no idea what your explaining there. Again sorry for my lack of knowledge to understand this.
I did make the change to the ? to \? and it is working , which is great !
This is what i have to allow 1 league on server 30 , league ID 63454 , you see all the different pages i have to direct to in order for 1 single league to show because of how their server sets up the leagues on it. Is there a shorthand way approach to this.
Sorry, too many years NOT speaking any Russian (and only one year at university level) so nothing’s left but a few memories of phrases.
Anyway, I was saying before that I suspected that your attempting to match query strings (within the {HTTP_REFERER} might not work). My test was to determine that you would receive the full query string from the {HTTP_REFERER} and validate your approach. :tup:
Because your {HTTP_REFERER} is being matched by regex, of course you must escape the ? character (otherwise, it’s the metacharacter for making the previous character optional). Kudos to you for doing this correctly!
Now, the “pirate image” I had referred to is another typical way to respond to bandwidth pirates: Instead of sending the linked image, send an image which states that the webmaster is a bandwidth pirate, i.e., don’t trust anything on that website! If you choose to return a “pirate image,” then you must exclude that image in an additional RewriteCond statement (testing the {REQUEST_URI} as NOT being the image). You’re not doing that so don’t mind my trying to help others.
Thanks for all your help ! I have one league completed but wanted to know if you see something in here where it can be shortened to include more url combinations on 1 line
Since the URL basically all begin with “football30.myfantasyleague.com/2012” and end it “?L=63454” , is there away to shorthand the combo directorie title in between
so using the .+ before the league ID catches the subs inbetween , i also added the .+ after the league id , for the URL that have a address after the league id