Please wait while we load your page...


HTACCESS Magic :: Page 3

Results 5 to 6 of 16

Deny Visitors by Referrer

Please note that restricting access on the basis of referrer is highly unreliable since many browsers may not pass referrer. For example, browsers set maximum privacy to not pass referrer. Further, referrer can be spoofed of faked. NOT recommended!

To block a single referrer, use the following Rewrite lines:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} somedomain\.com [NC]
RewriteRule .* - [F]

The Rewrite lines instruct the Apache Web Server to block traffic originating from

To block multiple referrers, use the following:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} somedomain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]

The Rewrite lines instruct the Apache Web Server to block traffic originating from and You add more in a similar manner.

Blocked referrers will be shown a "403 Forbidden" server error message. You can customise this error message by following the 'Error Documents' by adding the following:

ErrorDocument 403 /403.html

Then, create a 403.html page in root.

Note 1: To use Rewrite, (1) site must be hosted on an Apache web server, (2) mod_rewrite module must be compiled into Apache, and (3) mod_rewrite must be enabled for your domain.
Note 2: R=301 is a permanent redirect, and is the most efficient and "Search Engine Friendly" method for redirection. Alternatively, you can use R=302 for temporary redirect if the redirect is not permanent.

Last Revised: 2015-07-07

Disable Directory Browsing

Here are the lines to add to your .htaccess file to disable directory browsing (client's browser displays a Web page that lists the contents of a directory when a request does not specify a document name, and no index.html file exists in that directory):

# Disable directory browsing
Options -Indexes
# Set the default handler
DirectoryIndex index.php

The first line disables directory browsing. The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. In this case, if no specific file requested, the server serves index.php. This overrides server default of index.html. You can specify any file / file type. In most cases, the Options directive is not necessary since, by default, Apache (web server) is configured as "Options -Indexes".

Last Revised: 2015-08-30

Live Chat Not Available