singapore web hosting
singapore web hosting
Home
Subscribe RSS
singapore web hosting
 

Control Web Server - Use the Htaccess File

Posted February 21st, 2010

Even the best website with fantastic design is far from a perfect system if you don’t take care for security, redirection of www subdomain, error pages, etc. Many web servers including Apache support the .htaccess file which is a configuration file for web server configuration. This file can be used to tighten the security of the website, to password protect certain directories, to redirect old deleted pages to new addresses or to modify almost any web server setting. The .htaccess web server configuration file is well documented on many web pages–when you will need exact instructions on how to do something simply Google for it. You only need to know what is possible to do with this file.

Authorization and Authentication
You can restrict access to individual directories with .htaccess and .htpasswd files. This is very convenient because it is independent of the content management system and provides very high security.

Rewriting URLs
This means changing one url or web address into another. This is useful at least in two cases. Sometimes you will delete or rename old pages. To prevent displaying a “Page not found” error when somebody follows a link to the old page you can simply redirect the old url to the address of a new page. The other important use of url rewriting is to create shorter, search engine friendly urls with keywords.

Another use of rewriting is also to redirect www address to non-www address or vice versa. For historical reasons when web emerged all the websites used the www subdomain. There is no need to use it, but majority of sites still uses this kind of web address. And because some users type it and some don’t, you have to take care for both variants. The easiest way to redirect one address to another is by using the .htaccess configuration file.

IP Address Blocking
You can block individual IP addresses or domains. This is useful when you want to block some spiders, bots or even referrers.

Directory Listing
Usually you don’t want that visitors see the files in your directories. With the .htaccess configuration file you can easily prevent listing of any directory.

Custom Error Pages
Each error on the server side can be redirected to a custom page. This is much more user friendly than short error text reported by the server.

.htaccess file provides a powerful control over the web server. It can secure your website but it can also make it inaccessible. Make sure you have a backup copy before you change settings. If you have a website without the this file you are probably satisfied because the site works fine and you are not missing anything. But do you have a www to non-www redirection and nice error pages?

The author uses .htaccess file for every website he creates. For example, the http://revellmodelkits.com/ site is also accessible with the redirection is done with the .htaccess file. The rewriting function is also used to create short and meaningful addresses of each page like http://revellmodelkits.com/revell-model-airplanes for example.

Using .htaccess is simple. All the settings are well documented and easy to understand. However, in some cases you will need to understand also regular expressions which can be tricky. In the case of questions or problems you should ask Google first.

singapore web hosting
singapore web hosting
 
Hosting Recommendations
singapore web hosting
singapore web hosting
singapore web hosting
singapore web hosting


singapore web hosting
 
singapore web hosting