Live Chat Software by Champion Consulting
Knowledgebase : General
.htaccess tutorials

What Can I Do?

You may be wondering what .htaccess can do, or you may have read about some of its uses but don't realise how many things you can actually do with it.

There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file.

Creating A .htaccess File

Creating a .htaccess file may cause you a few problems. Writing the file is easy, you just need enter the appropriate code into a text editor (like notepad). You may run into problems with saving the file. Because .htaccess is a strange file name (the file actually has no name but a 8 letter file extension) it may not be accepted on certain systems (e.g. Windows 3.1). With most operating systems, though, all you need to do is to save the file by entering the name as:

".htaccess"

(including the quotes). If this doesn't work, you will need to name it something else (e.g. htaccess.txt) and then upload it to the server. Once you have uploaded the file you can then rename it using an FTP program.

Warning

Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning.

Custom Error Pages

The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found).

You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:

ErrorDocument errornumber /file.html

For example if I had the file notfound.html in the root direct
ory of my site and I wanted to use it for a 404 error I would use:

ErrorDocument 404 /notfound.html

If the file is not in the root directory of your site, you just need to put the path to it:

ErrorDocument 500 /errorpages/500.html

These are some of the most common errors:

401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page

Then, all you need to do is to create a file to display when the error happens and upload it and the .htaccess file.

Stop A Directory Index From Being Shown

Sometimes, for one reason or another, you will have no index file in your directory. This will, of course, mean that if someone types the directory name into their browser, a full listing of all the files in that directory will be shown. This could be a security risk for your site.

To prevent against this (without creating lots of new 'index' files, you can enter a command into your .htaccess file to stop the directory list from being shown:

Options -Indexes

Deny/Allow Certian IP Addresses

In some situations, you may want to only allow people with specific IP addresses to access your site (for example, only allowing people using a particular ISP to get into a certian directory) or you may want to ban certian IP addresses (for example, keeping disruptive memembers out of your message boards). Of course, this will only work if you know the IP addresses you want to ban and, as most people on the internet now have a dynamic IP address, so this is not always the best way to limit usage.

You can block an IP address by using:

deny from 000.000.000.000

where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will block a whole range.

You can allow an IP address by using:

allow from 000.000.000.000

where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will allow a whole range.

If you want to deny everyone from accessing a directory, you can use:

deny from all

but this will still allow scripts to use the files in the directory.

Alternative Index Files

You may not always want to use index.htm or index.html as your index file for a directory, for example if you are using PHP files in your site, you may want index.php to be the index file for a directory. You are not limited to 'index' files though. Using .htaccess you can set foofoo.blah to be your index file if you want to!

Alternate index files are entered in a list. The server will work from left to right, checking to see if each file exists, if none of them exisit it will display a directory listing (unless, of course, you have turned this off).

DirectoryIndex index.php index.php3 messagebrd.pl index.html index.htm

Redirection

One of the most useful functions of the .htaccess file is to redirect requests to different files, either on the same server, or on a completely different web site. It can be extremely useful if you change the name of one of your files but allow users to still find it. Another use (which I find very useful) is to redirect to a longer URL, for example in my newsletters I can use a very short URL for my affiliate links. The following can be done to redirect a specific file:

Redirect /location/from/root/file.ext http://www.othersite.com/new/file/location.xyz

In this above example, a file in the root directory called oldfile.html would be entered as:

/oldfile.html

and a file in the old subdirectory would be entered as:

/old/oldfile.html

You can also redirect whole directoires of your site using the .htaccess file, for example if you had a directory called olddirectory on your site and you had set up the same files on a new site at: http://www.newsite.com/newdirectory/ you could redirect all the files in that directory without having to specify each one:

Redirect /olddirectory http://www.newsite.com/newdirectory

Then, any request to your site below /olddirectory will bee redirected to the new site, with the
extra information in the URL added on, for example if someone typed in:

http://www.youroldsite.com/olddirecotry/oldfiles/images/image.gif

They would be redirected to:

http://www.newsite.com/newdirectory/oldfiles/images/image.gif

This can prove to be extremely powerful if used correctly.

The .htaccess File

Adding password protection to a directory using .htaccess takes two stages. The first part is to add the appropriate lines to your .htaccess file in the directory you would like to protect. Everything below this directory will be password protected:

AuthName "Section Name"
AuthType Basic
AuthUserFile /full/path/to/.htpasswd
Require valid-user

There are a few parts of this which you will need to change for your site. You should replace "Section Name" with the name of the part of the site you are protecting e.g. "Members Area".

The /full/parth/to/.htpasswd should be changed to reflect the full server path to the .htpasswd file (more on this later). If you do not know what the full path to your webspace is, contact your system administrator for details.

The .htpasswd File

Password protecting a directory takes a little more work than any of the other .htaccess functions because you must also create a file to contain the usernames and passwords which are allowed to access the site. These should be placed in a file which (by default) should be called .htpasswd. Like the .htaccess file, this is a file with no name and an 8 letter extension. This can be placed anywhere within you website (as the passwords are encrypted) but it is advisable to store it outside the web root so that it is impossible to access it from the web.

Entering Usernames And Passwords

Once you have created your .htpasswd file (you can do this in a standard text editor) you must enter the usernames and passwords to access the site. They should be entered as follows:

username:password

where the password is the encrypted format of the password. To encrypt the password you will either need to use one of the premade scripts available on the web or write your own. There is a good username/password service at the KxS site which will allow you to enter the user name and password and will output it in the correct format.

For multiple users, just add extra lines to your .htpasswd file in the same format as the first. There are even scripts available for free which will manage the .htpasswd file and will allow automatic adding/removing of users etc.

Accessing The Site

When you try to access a site which has been protected by .htaccess your browser will pop up a standard username/password dialog box. If you don't like this, there are certain scripts available which allow you to embed a username/password box in a website to do the authentication. You can also send the username and password (unencrypted) in the URL as follows:

http://username:password@www.website.com/directory/
Can I edit my website without downloading it?

Sure! If your account has shell access you can SSH to your web directory. From there, you can use pico, vi, or emacs to edit your web pages.

To get SSH enabled on your account please open a support ticket.

You can also login to your control panel and use File Manager to edit/update files.
ACTIVE: The registry sets this status. The domain can be modified by the registrar. The domain can be renewed. The domain will be included in the zone if the domain has been delegated to at least one name server.

REGISTRY-LOCK: The registry sets this status. The domain can not be modified or deleted by the registrar. The registry must remove the REGISTRY-LOCK status for the registrar to modify the domain. The domain can be renewed. The domain will be included in the zone if the domain has been delegated to at least one name server.

REGISTRAR-LOCK: The sponsoring registrar sets this status. The domain can not be modified or deleted. The registrar must remove REGISTRAR-LOCK status to modify the domain. The domain can be renewed. The domain will be included in the zone.

REGISTRY-HOLD: The registry sets this status. The domain can not be modified or deleted by the registrar. The registry must remove the REGISTRY-HOLD status for the registrar to modify the domain. The domain can be renewed. The domain will not be included in the zone.

REGISTRAR-HOLD: The sponsoring registrar sets this status. The domain can not be modified or deleted. The registrar must remove REGISTRAR-HOLD status to modify the domain. The domain can be renewed. The domain will not be included in the zone.

REDEMPTIONPERIOD: The registry sets this status when a registrar requests that the domain name be deleted from the registry and the domain has been registered for more than 5 calendar days (if the delete request is received within 5 days of initial domain registration it will instead be deleted immediately). The domain will not be included in the zone. The domain can not be modified or purged; it can only be restored. Any other registrar requests to modify or otherwise update the domain will be rejected. The domain will be held in this status for a maximum of 30 calendar days.

PENDINGRESTORE: The registry sets this status after a registrar requests restoration of a domain that is in REDEMPTIONPERIOD status. The domain will be included in the zone. Registrar requests to modify or otherwise update the domain will be rejected. The domain will be held in this status while the registry waits for the registrar to provide required restoration documentation. If the registrar fails to provide documentation to the registry within 7 calendar days to confirm the restoration request, the domain will revert to REDEMPTIONPERIOD status. The domain status will be set to ACTIVE only if the registrar provides documentation to the registry within 7 calendar days to confirm the restoration request.

PENDINGDELETE: The registry sets this status after a domain has been set in REDEMPTIONPERIOD status and the domain has not been restored by the registrar. The domain will not be included in the zone. Once in this status all registrar requests to modify or otherwise update the domain will be rejected. The domain will be purged from the registry database after being in this status for 5 calendar days.
How to edit an existing RvSitebuilder based site?

You can edit any site you have created using RvSitebuilder by following the steps below:

- Login to your Cpanel and click 'RvSiteBuilder' to load its interface.
- Under the 'Edit and Remove Project > Edit existing site' section you will find all the existing sites created with RvSiteBuilder in the drop down list.
- Select the one you want to edit and then press the 'Edit' button next to it.
- It will take you to Step 5 'Site Content' where you can edit, add, remove pages, or you can move to any other step to make the changes you want.
- After doing all the required changes, you can move to Step 7 'Publish' to publish the updated site.

<br /><br />
Although Champion Consulting offers WHMCS licenses to it's customers, support for the WHMCS software comes direct from WHMCS. To obtain assistance regarding issues that are impacting your WHMCS install, there are several options available to you to be able to retrieve support.<br /><br />
<ul>
<li>You may <strong>ticket WHMCS directly</strong>&nbsp;to obtain end-user support by following this URL:&nbsp;<a href="https://www.whmcs.com/members/submitticket.php?step=2&amp;deptid=13">https://www.whmcs.com/members/submitticket.php?step=2&amp;deptid=13</a>&nbsp;</li>
<li>For the adventurous type, referring to WHMCS' detailed <strong>documentation/wiki</strong> may be more your thing:&nbsp;<a href="http://wiki.whmcs.com/Main_Page">http://wiki.whmcs.com/Main_Page</a></li>
<li>Interact and obtain support from other WHMCS customers at their <strong>community forum</strong>:&nbsp;<a href="http://forum.whmcs.com">http://forum.whmcs.com</a></li>
</ul>
<br />WHMCS provides not only great software, but also great support. Who better to support the software than the creators themselves? If you have any issues regarding your WHMCS install, please refer to the links above for assistance.
<br /><br />

What are the types of web site statistics that you provide?

We provide the following types of web site statistics and reports: awstats, webalizer, latest visitors, bandwidth, and error logs which gives you extensive stats, such as total number of hits, most requested pages, terms searched for, and amount of bandwidth generated by your site. This information will help you effectively determine how to market your site as well as monitor its growth. We also provide Raw Access Logs which can help to investigate website activity and possible issues. Please enable archiving in Raw Log Manager to keep raw access logs longer than 24 hrs.
What is a blog?

Having heard the term previously but not having paid much attention, most are just too afraid to show their ignorance by asking the question, "What is a blog?".

Blogs are web logs that are updated regularly, often on a daily basis. They contain information related to a specific topic. In some cases, blogs are used as daily diaries about people's personal lives, political views, or even as social commentaries. Businesses use them for announcements, to provide help to their customers, to engage and get feedback from their customers, etc.
What is SEO?

SEO stands for Search Engine Optimization. Its the process of studying the search engines in an effort to determine how to get your web site to rank high on user searches. Rank is the position in the search engine results page that a web site appears when someone searches for a specific keyword or keyword phrase.

It's possible to get a significant amount of free traffic from the major search engines if you properly optimize your web site pages to get in the top results returned from a search.

Help Desk Software by Champion Consulting