Prevent hotlinking with htaccess and mod_rewrite
To stopping content stealing, just create an .htaccess file (or add to the existing file) and paste code below and upload/save it to your main directory(root of your homepage).
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC]
RewriteRule \.(bmp|gif|jpg|jpeg|png|mp3|swf|avi)$ - [NC,F,L]
You can replace requested files with a ' don't hotlink' image file.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursecondsite.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?forum.example.com(/)?.*$ [NC]
RewriteRule .*\.(bmp|gif|jpg|jpeg|png|mp3|swf|avi)$ http://www.example.com/stophotlinking.jpg [R,NC]
Similar entries
- .htaccess examples
- Url manipulation with mod_rewrite and php-catcher for beginners
- Redirect webpages with HTML, PHP, .htaccess, Java+Script, CGI-Perl, ASP.NET and ColdFusion
- Page generation time and http-referers with PHP
- Replace string in big database or large text file
- Image watermark with PHP
- Howto protect admin.php / login.php with htaccess password
- Set auto_prepend_file with .htaccess on Hosteurope managed hosting
- Upload multiple images with PHP
- [warn] [client 1.2.3.4] mod_fcgid: HTTP request length 137744 (so far) exceeds MaxRequestLen (131072), referer
- Fix swfupload fake flash player error
- Photo Album / Picture Gallery Script with PHP
- Smart Multi-Uploader and Thumbnail Creator from GIF/ JPEG/ PNG with PHP
- Web Application Security Papers
- Best free image-editors for Windows
- How do I secure my web site?
- php
- Redirect a query to multiple search engines with one form and javascript
- Packet Sniffing and Monitoring with Tshark / Wireshark
- Notepad++ Unable to create directory for file C

Comments
Post new comment