htaccess files are available on our Advanced and Reseller Hosting Plans only. They are an excellent way to manipulate visitors to your website.
Register Globals
For security reasons, all servers have 'register_globals' turned off by default.
If any client needs register_globals to be 'on' this can be done by adding the following line to a .htaccess file in the directory where the script is running ...
php_value register_globals 1
Any client making this change should be aware of the security implications of doing this and be prepared to take responsibility should a script compromise occur as a result of the setting.
Ignore Index Page
Because 'http://www.change-domain.com/index.html' is a location in its own right it displays the same content as 'http://www.change-domain.com'. As such, some search engines consider this to be duplicate content which can then affect site rankings.
To overcome this you can put the following into a .htaccess file ...
Note ... replace 'change-domain.com' with your actual domain name.
After doing this, anyone who enters http://change-domain.com/index.html into the browser will be redirected to http://www.change-domain.com.
Force WWW
To force all website visitors to use the www. part of the domain in the URL (useful for search engines) you can put the following into a .htaccess file ...
Note ... replace 'change-domain.com' with your actual domain name.
After doing this, anyone who enters http://change-domain.com into the browser will be redirected to http://www.change-domain.com.
Modify 'upload_max_filesize'
PHP's upload_max_filesize value is set server wide to 2mb but can be modified (as with some other PHP variables) by adding the following to your .htaccess file ...
php_value upload_max_filesize "6M"
Note ... replace the number 6 with the new limit you wish to set in MB
After doing this, the upload_max_filesize limit will be changed for that account and can be seen by viewing a phpinfo page.
Stop Directory Browsing
To disable directory browsing you can add the following to your .htaccess file ...
Options -Indexes
Redirect a Parked Domain
Most search engines frown upon duplicated content so if you have two or more domains mapped to the same hosting account, when a searchbot indexes both sites they will each show as having the exact same content.
To avoid this, you can add the following to your .htaccess file ...
In the above example, any visitors to 'http://change-domain.com' will be redirected to 'http://www.change-domain.co.uk'.
Options +FollowSymLinks All -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.change-domain.com [NC]
RewriteRule ^(.*)$ http://www.change-domain.co.uk/$1 [L,R=301]
In the above example, any visitors to 'http://www.change-domain.com' will be redirected to 'http://www.change-domain.co.uk'.
Redirect to a Folder
In some cases you might have a redirection setup on your index page which points to the real home page of your site in a sub-directory or separate folder. In order to ensure search engines index the correct home page you need to set up a permanent redirection DirectoryIndex filename.html...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?change-domain\.com$
RewriteRule ^$ http://www.change-domain\.com/subfolder/ [R=301]
The above example will redirect all visitors to a subdirectory named 'subfolder'.
Different Homepage Name
Instead of calling your website homepage one of the main default names such as: index.htm, index.html, index.php, etc, you can add the following htaccess coding and name it whatever you like ...
DirectoryIndex myhomepage.php
The above example will treat the file 'myhomepage.php' as your new homepage.
Download File Instead of Open File
You can force the download a file instead of having it open in a browser window. To do this, enter the following code followed by the appropriate file extension ...