RewriteCond %{HTTP_HOST} ^www\.yoursite\.com$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [L,R=301]
RewriteCond %{HTTP_REFERER} !^http://yoursite.com [NC]
RewriteRule .*\.(SVG|pdf)$ http://yoursite.com/nohotlinking [NC,R,L]
.htaccess hotlink protection
Jan 16, 2009
Protecting your site from hotlinks can be really useful to prevent other sites stealing bandwidth, but it's also comes handy when you want to protect files from private areas.
The first 2 lines are responsible from redirecting all the traffic from www.yoursite.com to yoursite.com and the third and fourth line is for preventing hotlinks, in this case PDFs and SVGs. You can add more file types.
Post new comment