Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

migrated from serverfault.com Sep 21 '11 at 6:17

This question came from our site for professional system and network administrators.

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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