MyBB Community Forums

Full Version: Disable Hotlinking
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hosting Company.

This code allows images that start with http://www.htaccesselite.com and deletes all others:

To use it, edit the file viewtopic.php and search for
CODE: SELECT ALL
$message = str_replace("\n", "\n<br />\n", $message);

and then paste the following directly under it.
CODE: SELECT ALL
$message=preg_replace('@<img src="http://www\.htaccesselite\.com([^>]*?)>@si','<img class="iok" src="http://www.htaccesselite.com\\1>',$message);
$message=preg_replace('@<img src="[^>]*?>@si',"",$message);

I actually found this code while browsing. Does anyone know where I could put it? The post says the viewtopic.php but I can't seem to find it.
No need of any code.

Go to your CPanel, look for Security -> HotLink Protection

In "URLS allowed to access" give your forum paths, that you access regularly.
http://domain.com/forum
http://www.domain.com/forum

In "Block access to extensions" give the image extensions you like to block.
.png, .jpeg, ..............

"Allow direct request" selected and the click on submit/ok
I went to my DreamHost CPanel on our hosting account and didn't see anything. I then did a "live chat" with them and after explaining what I needed, they finally said:

kacy: No we don't have a place in our control panel to prevent hotlinking

and

kacy: sorry

So, guess that is out. Sad
add this to your root .htaccess

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/$      [NC]
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
But from what I understand, isn't this the code to prevent people from hotlinking to my images?

I want it the other way around. I don't want anybody on my forum to hotlink to images on other websites. I only want them to use images off our server that they have uploaded to the file uploader.
Pages: 1 2