How to configure your .htaccess

Some of the configurations on the web server dedicated for shared hosting are set up by the hosting administrator and users can not change them (like disk space limit per one hosting or email account, data transmission limit and so on). But there are some configurations that may be changed on users level. You can change those configurations creating a file named .htaccess in the main directory of your domain on FTP. Configurations that has been set in this file are valid for the directory where the .htaccess file is located, as well as all directories located on lover levels. If one of the subdirectories has another .htaccess file, the configuration of this file overrides the settings for each previous file level for this subdirectory.

The .htaccess can set a series of parameters and regulate access. This file is used for:
  • Establish a redirection (for ex: free domain -> paid);
  • Configuration of user friendly URLs;
  • Set up your own 404 error page for each of your domains;
  • Cache control;
  • Restriction of the access to directories or files;
  • Adjusting other parameters.

IMPORTANT: you can not configure php_flag and php_value parameters in your .htaccess file on our hosting. If you include those parameters in your .htaccess file you will see an error on your main page.

If you want to set up your own error page, you can not use an ErrorDocument directive - it is ignored by default. A custom error page can be configured only on Pro and VIP accounts by loading a file named 404.html to the directory /errors (you can create this directory by edding a folder in the main folder of your domain on FTP).

Below you can see a sample of some frequently used directives you can set in .htaccess file. We presume that you locate the .htaccess file in the main directory of some domain on FTP.


Options directive
Options -Indexes - in case there is no index.html or index.php file in the directory where .htaccess is located, you will see a 403 error on the main page. In case there is index.html or index.php file in the main directory, you will see the content of that file. Our hosting forces -Indexes, so there is no point to include this directive in your .htaccess on our hosting.
Options +FollowSymlinks tells the web server to follow so called symbolic links. Symlinks are disabled on our hosting for security reasons.

RewriteEngine On - enables a possibility to set up redirections between domains and subdomains, enable friendly URLs, and more.

If you do not use .htaccess, your links may look like this: happyuser.zz.com.ve/index.php?q=webpagename. It is hard to remember and read this address. To make it better, so called friendly addresses were invented. If you configure your .htaccess to use friendly URL, your address will look like this: happyuser.zz.com.ve/webpagename.

Let's see how to enable the usage of friendly URLs:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?q=$1 [L]

Another function that is frequently used in .htaccess is a restriction of the access to some directories or files located on the FTP. You can make them accessible only to the owner of the page or the FTP server software, but not for site visitors. To do that, place in the desired directory a .htaccess file with this directive: Deny from All. Than when someone tries to get into the directory, the web server will return a 403 Forbidden error. But the owner of the site can access that directory via FTP.

One more thing you can do using .htaccess file is to set redirection from www.yourdomain.zz.com.ve to www.yourdomain.zz.com.ve - if you want your domain to be visible without the www prefix.To set this redirection, create a .htaccess file with thore rules inside:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.happyuser\.zz.com.ve $ [NC]
RewriteRule ^(.*)$ http://happyuser.zz.com.ve/$1 [R=301,L]

The http://www.happyuser.zz.com.ve/onepage.php queries will be redirected automatically to http://happyuser.zz.com.ve/favorite-page.php.

There are many more directives that you can use in .htaccess to configure your website.