Forum Moderators: phranque
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
But I also have a condition to allow requests from my domain, ex:
RewriteCond %{HTTP_REFERER}!^http://(.*).mydomain.com/.*$ [NC]
How would I prevent users of tools like Wget from changing the referrer to mydomain.com to bypass the rewrite - can I specify the acceptable Remote Address of the Referer in the same line, something like:
RewriteCond %{HTTP_REFERER}!^http://(.*).mydomain.com/.*$ ¦ %{REMOTE_ADDR} ^0.0.0.0 [NC]
First, {REMOTE_ADDRESS} refers to the IP address of the client and not the referrer, and second, your RewriteCond is syntactically incorrect -- all envars must be on the left side of the RewriteCond.
If your WGET blocking rewrite precedes the referrer check in your code, then WGET will be blocked regardless of the referrer, so there is no problem here. If WGET is still able to access your site, then the problem lies in the existing code, not in code that is missing and needs to be added.
Jim
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_REFERER} !^http://(.*)mydomain\.com/ [NC]
RewriteRule \.(gif¦jpg)$ - [NC,F]
Jim
There are all sorts of things that can cause a rule not to be processed. For example, if you have missing closing parentheses, curly-braces, or square brackets, or an [OR] on the *last* RewriteCond of a RewriteRule that precedes the one that doesn't work. Or it may be that your expectations don't match your code; For example, your rule will stop Wget or referrals from unathorized sites from fetching images (.gif and .jpg), but not pages (.html).
Jim