Need htaccess help!


#1

I’m trying to block one specific webpage from hotlinking something from my site. I don’t want to block anything else, just this one guy. I’ve done it with other pages, but unfortunately, something is throwing a wrench into the works – the URL (EXAMPLE.com/EXAMPLE.phtml?user=EXAMPLE) contains a question mark, and it’s causing my entire site to crash when I upload the modified .htaccess

Is there any way I can get this to work?

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www.)?EXAMPLE.com/EXAMPLE.phtml?user=EXAMPLE*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www.)?EXAMPLE.com/EXAMPLE.phtml?user=EXAMPLE*$ [NC]
RewriteRule .(jpg|jpeg|gif|png|bmp)$ http://www.MYSITEHERE.net/images/nohotlink.gif [R,L]


#2

I maybe much help as I am still learning htaccess stuff. But I did find out that chmod must equal 644 or all havoc will break loose.
Silk


#3

try escaping the ? in the url, ie: ?

A ? has a specific symbolic meaning in regexps and you need to escape it if you want it to be treated literally.


#4

Ahh, thank you. That did the trick!

(You’re my new hero!) :stuck_out_tongue_winking_eye:


#5

There is a comprehensive article about this on the DreamHost wiki: Preventing image “hotlinking”


Simon Jessey
Keystone Websites (business site) | si-blog (personal site with affiliate links)


#6

The Wiki didn’t cover the issue I was having with the question mark. It’s been sorted out now, anyway, and I thank you for taking the time to respond to my post. :slight_smile: