Apache .htaccess file

We have all visited a website as your currently viewing my blog which is a website, when you visit a website you download the files and data required for your web browser to display the desired page. The computer or server which you download a website from will be running some form of web server which is an application used to distribute the required files and code to a web browser requesting them. There is a range of web servers available but in this post I will be talking about the Apache web server and its .htaccess file.

A web server has a range of configurable options but due to every website being different you need a way to specify an option for one but not the other this is where the .htaccess file comes in. It allows you to configure options which will affect only the site it is run from, this file can be used for a range of settings such as configuring apache options (not all options are changeable due to security risks) to setting up redirects and passworded directories.

The .htaccess can be located in the main directory or any sub directory if it is placed in the main directory the settings in this file will normally apply to all files and subdirectories, where as placing it in a folder will normally only apply to that folder and its subdirectories.

Creating the .htaccess file

Creating this file on a Linux operating system is simple and the normal file creation and naming method is suitable, on windows this is a different story as Windows operating systems do not allow you to specify .htaccess as a valid file name, when you create a file on windows you normally have the name of the file and then the file exstension like below.

As we need to call are file .htaccess without an extension Windows throws a wobbly and so we have to call the file htaccess and then use the following command prompt to rename the file to .htaccess.

So here is an example of me renaming my file which is located on my desktop.

Ultimate .htaccess Guide

The people at Who Is Hosting This, have created a very good guide suitable for beginners to experts. Take a look.


Other commands

You can find all my other posts related to .htaccess and how you can perform specific tasks by viewing my other blog posts which can be found here.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.