Archive for » November 6th, 2009«

Stop hotlinking from outside domains by using .htaccess?

How to stop hotlinking from outsides domains.

You can stop the hotlinking from outsider domain by using following rule in .htaccess

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+.)?domain.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?domain1.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?domain2.com/ [NC]
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

You can also display a 403 Forbidden Error page instead of an image (nohotlink.jpe)

Replace last line on above code with the following code

RewriteRule .*.(jpe?g|gif|bmp|png)$ – [F]

WordPress default .htaccess file?

The default wordpress .htaccess file code is as follows

# BEGIN wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_fileNAME} !-f
RewriteCond %{REQUEST_fileNAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END wordpress