How to Hot Link Protect Your Files by .htaccess File

htaccess file, Programming
The hot link Protection technique allows you to prevent other websites from directly linking to files on your website. This is most commonly used to prevent other web sites from displaying your images but it can be used to prevent people using your JavaScript or CSS (cascading style sheet) files. The problem with hot linking is that it uses your bandwidth, which in turn costs money, hot linking is often referred to as 'bandwidth theft'. If you are using hot link protection technique, other websites that hot link to your files will display an error or show nothing. This means that when another website is visited, it cannot load pictures from your pages - this is one of the ways for limiting the outbound traffic for your account. An example…
Read More

How to Block Visitors from Spam Referrers By .htaccess file

htaccess file, Programming
When you notice a surprising increase in traffic and check your logs one day, and see tons of referrals from a particular site, yet upon inspection you can't find a single visible link to your site on theirs.  The referral isn't a "legitimate" one, with the site most likely pinching content or hot linking to certain files on your site such as images, .css files, or files you can't even make out it means that someone is attempting to hack your web site (this may simply mean trying to find non public content). You will another big usage of .htaccess file: Blocking users or sites that originate from a particular domain. The following code will block any visitor by referrer: RewriteEngine on Options +FollowSymlinks RewriteCond %{HTTP_REFERER} thisbad_domain\.com [NC] RewriteRule .* -…
Read More

Password Protect A Directory or A Single File by the .htaccess file

htaccess file, Programming
Protecting files on your website from unauthorized users can be very important. You could use PHP to listen for login authorization information on each page, but that doesn't protect your images, documents, and other media?  The password protection and authentication systems offered by the Apache Web Server are probably one of the most important use of .htaccess file.  Very easily, we can password protect a directory (or multiple) of a web site which require a username and password to access. Password Protection for a Directory The method is called htaccess password protection or htaccess authentication, and works by uploading One file called .htaccess  in the directory you want to password protect.  The htaccess file should contain the following: AuthType Basic AuthName "The Member Zone Name" AuthUserFile /path/to/password/file/.htpasswd require valid-user It…
Read More

Custom Error Responses by .htaccess ErrorDocuments following HTTP response status codes

htaccess file, Programming
One of the important use of the .htaccess file is to redirect users to a custom error page depending on the specific web server error they encounter.  Your website visitors need know why the page which he/she is visiting does not exist any more, what happens to the page that he is visiting. Search Engine like google need know why the pages are missing too. For good visitor experience and good SEO results, you need customer error pages. Creating custom error pages is very useful, it allows you to show web site visitors and search engines a friendly error message, for instance if a URL on your web site does not work. This avoids the unfriendly ‘404 File Not Found’ error and allows you to display a friendly error, explaining…
Read More

How to deny IP addresses by .htaccess

htaccess file, Programming
To ban a single IP address from accessing your Website, add following code to the .htaccess file in the root directory of your html file. If you donot have .htaccess file in your root directory, you can create one. FTP and file manager can help you to create .htaccess file. Please remember the "." before htaccess. "." means hidden file. order allow,deny deny from 79.09.9.8 deny from 221.138.7 allow from all The above lines tell the Apache Web Server to block visitors from the IP address '79.09.9.8' and '221.138.7', note the second IP address is missing the fourth set of digits, this means any IP address which matches the firth three set of digits will be blocked, e.g. '221.138.7.1' , '221.138.7.2' till '221.138.7.255' would be blocked. If you want to block…
Read More