What is .htaccess?

By Joe Gardiner Monday, 22nd March 2010

In order for requests to be passed between the static content tier of web servers and the dynamic/application tier, it is important to ensure the .craccess and .htaccess files contain the correct information.

If they do not, your php applications, especially CMS's, may display some errors, or have features working incorrectly.

How does it work?

Both files offer apache settings overrides at different tiers in the CatN stack. The .craccess file offers configuration overrides at the static content tier, and the .htaccess at the dynamic/application tier.

The .craccess file is offers exactly the same options as the .htaccess file but is specifically configured for the static content tier of the CatN stack.

The .htaccess file was originally used for per directory access configuration in apache web server, but is now used for many more configuration settings, such as cache control, customised error responses, and responses to varying file types.

Finding these files

In order to view these files you must be able to view hidden files and folders in either your FTP client, or using the correct ssh command.

Hidden files in FileZilla

Open up FileZilla, and connect to your vCluster access server. Have a look at this guide if you're unsure how to do this.

Click the "Server" option from the menu bar and select "Fore showing hidden files". This will display hidden configuration files in all folders you view through FileZilla.

As you can see in the following picture, the .cracess file and .htaccess files are now displayed in my wordpress install root folder.

Displaying files in SSH

In a secure shell environment using the the -a switch on the ls command displays hidden files with a "." prefix. For example:
[youtube video="xSxfNrvWv2U" author="by Joe Gardiner" bgcolor="#000000" color="#336699" hd="true" height="300" title="SSH hidden files ls -a switch" width="500"]

Correct contents

The correct contents of these files are as follows...

.craccess

RewriteEngine On
RewriteCond %{REQUEST_URI} !.(gif|jpe?g|png|css|js|ico)$
RewriteRule ^(.*)$ http://YOUR PRIVATE IP/$1 [P,L]

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

If these files do no exist in the root of your directory or CMS install, create them in a text editor, save as .craccess or .htaccess and upload to the root folder.

Double check the file names however, as some text editors add their own file extensions, such as .rtf or .txt. Using FileZilla, it is simple to rename a file if this has occurred.


Posted in Advanced Configuration, Guides | No Comments » twitter-follow facebook-follow rss-follow

Leave a Reply

Your email address will not be published. Required fields are marked *