justuptime.com - monitor your servers & websites

Hotlink protection with a query string?

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

He has: 238 posts

Joined: May 2002

I have a whole bunch of images at somesiteblah32214.com

.. and I want them to only be used on my own myspace account.

Here's what I was able to come up with:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(https?://([^/]*\.)?myspace\.com/myusername)$ [NC]
RewriteCond %{QUERY_STRING} !^friendid=123456789$ [NC]
RewriteRule .* - [F]

'

However, I cannot for the life of me get the query string part to work. I need to make it so that the rule is true if it doesn't contain "friendid=123456789" anywhere in the query string.

Thanks.

nuk3.com | Free funny flash movies and addictive games

He has: 238 posts

Joined: May 2002

I ended up working out the problem by realising the query string is apart of the referrer (in most cases anyway), so I came up with this code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(https?://([^/]*\.)?myspace\.com/myusername)$ [NC]
RewriteCond %{HTTP_REFERER} !.*friendid=0123456789.* [NC]
RewriteRule .* - [F]

'

It allows me to hotlink images from my website on just my own MySpace account.

kk.

nuk3.com | Free funny flash movies and addictive games