Prevent Hotlinking From Your Proxy Website and Save Bandwidth

Posted by Vectro 0 comments

When someone hotlinks your proxy pages, it can eat precious bandwidth which costs money. This occurs when a user browses to a page via your web proxy, then copies the proxied URL and pastes it on a web page or forum. The hotlink protection built into PHPRoxy is extremely weak. Glype’s anti-hotlink feature works better, but is not perfect. The purest way to block hotlinkers is at the server level. This is done by modifying (or creating) an .htaccess file. This only applies to Linux web servers. If you’re not sure, ask your host.

Here is the code to place in your .htaccess file. If you already have a file with this name, add the snippet to the very bottom. If not, just create a file with that name, add the code and upload it to the root directory of your website. Make sure to replace all 5 instances of example.com with your actual domain name. If you have one .htaccess file controlling all of your sites, paste the code as many times as you need.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://example.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.com$ [NC]
RewriteRule .*\.(.*.*.*gif|jpg|jpeg|png|bmp|tif|tiff|php)$ http://example.com/403.shtml [R,NC]

This code might block PHP pages from being linked to from outside sites. Your home page at the root of your domain name can be linked to without a problem. However, a link to a page such as example.com/page1.php from an outside sight may end up being blocked. Fortunately, most proxy sites don’t have any pages besides the homepage. If yours does, the solution is to place all extra .php pages (except index.php) into a separate directory (such as example.com/webpages/), then create a new .htaccess file for that directory only and use the following code:

RewriteEngine on
RewriteRule ^.*$ -

Go back to the root directory and edit the original .htaccess file. Be sure to set up a search engine friendly redirect for each of the old pages to make sure search engines don’t lose track of them:

RewriteEngine on
redirect 301 /page1.php http://example.com/webpages/page1.php

Be sure to change page1.php to the name of the actual page and change example.com to your actual domain name. Do this for each of your pages, putting each entry on a new line.

PHP Proxy Hosting with Specialized Features and Tech Support

Sorry, comments are closed.

Previous Post
«
Next Post
»

Optimized by SEO Ultimate