0

People are able to embed my forum's attachments (vbulletin). I tried to create an htaccess rule for the hotlinking, but it did not work.

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com.*$ [NC]
RewriteRule attachmentid=\d+(\&d=\d*)?|\.([Gg][Ii][Ff]|[Jj][Pp][Gg])$ http://mydomain.com/antihotlink.jpeg [R]

Is it not possible to check for numbers in regular expressions in htaccess files?

  • 1
    Please provide an example of attachment URL that you are trying to work with. – LazyOne Sep 21 '11 at 8:53
  • Are you sure your pattern isn't just wrong? You're not telling us what you're trying to match, so it's not really possible to answer the question. – Su' Sep 21 '11 at 8:56
  • I want to match an url like this: mydomain.com/forum/attachments.php?attachmentid=123456 with an optional "&d=123456" at the end... – reggie Sep 23 '11 at 16:53
1

You have to use RewriteCond %{QUERY_STRING} to match against the query string -- rewriterule matches only against the path component of the URL.

That's why your rule is a no-op.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.