For our Free and Paid Linux accounts we support the use of .htaccess files, but for security reasons we do limit its use and only allow the following functionality. Below are some of the most common reasons and methods of using the .htaccess file.
Password Protection allows you to have a folder or specific file password protected, this means when someone tries to browse to that folder or file a box will come up requesting they fill in a username and password.
To achieve this password protection you will be actually using two files, one is the .htaccess file and the other is the .htpasswd. Lets say I want to create a user “bob” with the password “smith” and protect the following folder “x.mydomain.com/secret” Below is what I would put in the files:
.htaccess file should contain
AuthName "Members Only"
(Use the line above only if your account is oncloud, XXX's are your subscription ID)
<limit GET PUT POST>
.htpasswd files contain the user name and password which looks like:
The password field is encrypted and you can not enter clear text. To calculate the DES-encrypted value of a password you can use this tool.
You can make these files using any text editor you choose (notepad for example) and then upload them to the /docs/secret folder on your Linux account.
File Types / Redirections / Customized Errors
A few other things you can do with the .htaccess is add in additional file types to be rendered in the browser. Below is the common line you would need to add in if you wanted .WAP.WML to load properly on cell phones and other devices.
AddType text/vnd.wap.wml wml
If you wanted to have someone visit http://x.yourdomain.com/search and be redirected to google.com you could do the following:
Redirect /search http://www.google.com
If you want to setup customized error messages on your site then it can also be done via the .htaccess file. Most commonly this is done for 404 errors (file not found).
ErrorDocument 404 /missing.html
Changing Your Index Page
The last most common use of the .htaccess file is to add in extra “start” filenames for your site. I’m sure you already know that generally you need to name the first page of your website index.html in order for it to load properly, but with .htaccess, it allows you to change it to anything you wish.
Adding A MIME Type
If you want to add additional MIME types to your site you can do so from your .htaccess.
AddType MIME_Type_Name Extension
For example, if you wanted to add the MIME type for image/jpg, you could include the following entry in your .htaccess file:
AddType image/jpg .jpg
Directory Indexing with .htaccess
At this time directory indexing cannot be enabled using the .htaccess file.