Apache Redirects (.htaccess)


Note: .htaccess feature is not available with Tomcat Hosting since Tomcat is used instead of Apache. However, our PHP hosting plans do support .htaccess rules.

An htaccess file is a simple ASCII file, such as you would create through a text editor like NotePad or SimpleText. Many people seem to have some confusion over the naming convention for the file, so let me get that out of the way.

.htaccess is the file extension. It is not file.htaccess or somepage.htaccess, it is simply named .htaccess

In order to create the file, open up a text editor and save an empty page as .htaccess (or type in one character, as some editors will not let you save an empty page). Chances are that your editor will append its default file extension to the name (ex: for Notepad it would call the file .htaccess.txt). You need to remove the .txt (or other) file extension in order to get yourself htaccessing--yes, I know that isn't a word, but it sounds keen, don't it? You can do this by right clicking on the file and renaming it by removing anything that doesn't say .htaccess. You can also rename it via telnet or your FTP program, and you should be familiar enough with one of those so as not to need explaining.

htaccess files must be uploaded as ASCII mode, not BINARY. You may need to CHMOD the htaccess file to 644 or (RW-R--R--). This makes the file usable by the server, but prevents it from being read by a browser, which can seriously compromise your security. (For example, if you have password protected directories, if a browser can read the htaccess file, then they can get the location of the authentication file and then reverse engineer the list to get full access to any portion that you previously had protected. There are different ways to prevent this, one being to place all your authentication files above the root directory so that they are not www accessible, and the other is through an htaccess series of commands that prevents itself from being accessed by a browser, more on that later). Note: With Java|Pipe servers, you cannot view the .htaccess file with normal ftp login. You can either view them in shell with the command: ls -a or use the file manager in the site admin control panel.

Most commands in htaccess are meant to be placed on one line only, so if you use a text editor that uses word-wrap, make sure it is disabled or it might throw in a few characters that annoy Apache to no end, although Apache is typically very forgiving of malformed content in an htaccess file.

htaccess is an Apache thing, not an NT thing. There are similar capabilities for NT servers, though in my professional experience and personal opinion, NT's ability in these areas is severely handicapped. But that's not what we're here for.

htaccess files affect the directory they are placed in and all sub-directories, that is an htaccess file located in your root directory (yoursite.com) would affect yoursite.com/content, yoursite.com/content/contents, etc. It is important to note that this can be prevented (if, for example, you did not want certain htaccess commands to affect a specific directory) by placing a new htaccess file within the directory you don't want affected with certain changes, and removing the specific command(s) from the new htaccess file that you do not want affecting this directory. In short, the nearest htaccess file to the current directory is treated as the htaccess file. If the nearest htaccess file is your global htaccess located in your root, then it affects every single directory in your entire site.

Before you go off and plant htaccess everywhere, read through this and make sure you don't do anything redundant, since it is possible to cause an infinite loop of redirects or errors if you place something weird in the htaccess.

Also...be careful when you use htaccess files, since depending on what they are doing, they can slow down a server overloaded with domains if they are all using htaccess files. I can't stress this enough: You need to make sure you know what you are doing when using htaccess before you actually use it. Some things that htaccess can do can compromise a server configuration that has been specifically setup by the Java|Pipe admin, so don't get in trouble.


  1. Error page redirects
  2. Change your default directory page
  3. Redirects
  4. Prevent hot linking of images

In any event, I hope you got a better idea of the power available to you through this relatively simple file. You really do have the ability to save yourself a lot of time and grief by using htaccess. If you have any questions about using .htaccess please submit a ticket.

  • 52 Users Found This Useful
Was this answer helpful?

Related Articles

GD and Imagemagick

GD - What is it? gd is a graphics library. It allows your code to quickly draw images complete...


JavaPipe Nameservers Name Server IP address Servers NS1.DHSERVER.NET...

Subversion SVN

JavaPipe offers a free subversion repository with its Java Tomcat hosting packages. This...

Can I access my domain without the "www" in front?

Yes. You will be able to access your domain address with or without the "www" in front of the...

Can I point additional domains to the same main page as my current domain?

Yes. This is also called Pointer domains in Siteworx or Parked domains in cPanel. Please see the...