How to block access from a referrer using htaccess
This web hosting tutorial shows you how to block access from a referrer using htaccess using our advanced Hepsia web hosting control panel. This video tutorial is also available inside the OzeVision Web Hosting control panel under Help/Video Tutorials.
Our web servers are set to display at first a file called "index". For instance:
index.html index.htm index.php index.pl
This is the default server configuration, so whenever a visitor types your domain e.g. my_best_domain.com in a browser, the server would look for the index file located in your domain''s main folder and display it to the visitor. You can change the directory index file with a custom .htaccess file. Learn more on this topic here: Changing the directory index file
But what if you don''t have an index file in a certain directory? It could be a problem if you have a web folder which doesn''t contain such a file or the default index page is not set. Imagine that you have a sub-directory inside the main directory of your domain: my-best-domain.com/directory
There is no index file inside it, so whenever a visitor visits my_best_domain.com/directory, the directory content will be listed in the borwser. You can hide the directory content in order to avoid visitors seeing files that are not supposed to be displayed. There are several ways to hide the directory structure of your website:
Option 1
You can simply create an emtpy index.html file and put it inside each folder that has no actual index file. This may be a time-consuming task, especially if you have many sub-folders.
Option 2
Changing the directory permissions to 711. If you set the permissions of a certain folder to 711, this would effectively disable directory listing. You have to use an FTP client to set the permissions. Please refer to the following article, which explains how you can change permissions via FTP: How to change the permissions of a file or a folder
Option 3
Use a custom .htaccess file to disable directory listing or exclude certain file types from the listing. Using an .htaccess file - a system configuration file, you can change the way the web server treats directories where an index file is missing. You are able to exclude certain or all files from the directory listing. What is great about this method is that rules in the .htaccess file work recursively, so they would be valid for all sub-directories. So, if you put the .htaccess file in the main domain folder, all the rules inside it will be valid for all the sub-directories. To use this method, first create an empty .htaccess file inside the directory in question - usually your domain''s main directory, via the File Manager - Site Management/File Manager - section of your Web Hosting Control Panel. Once you have created the empty .htaccess file, click on the ''Edit'' icon on its right and choose the plain text editor. Put the following code in the file and save it:
IndexIgnore *
The above rule excludes all files from the directory listing.
Tags: block access, block referrer, hepsia control panel, web hosting tutorial