Use .htaccess mechanism to redirect trafic with Apache [Apache-1]

When you create a website, you may want to store all the content in a dedicated directory. The plus with this way of doing is the ability to easily change for future versions of your blog. You will just have to play with the directory by moving, renaming, etc.

The problem when you do that, is to redirect the users from the root address to this directory.

If your web server is Apache, which is more than probable when you see the usage of web servers for websites.

Then you can create an configuration file named .htaccess with the following content at the root of your domain:

RewriteEngine On
RewriteRule ^$ /blog [L]

^ at the second line mean the beginning of the line, and $ means the end. Their combination means redirect the whole line (aka the actual URL) to the blog directory. The [L] at the end stands for this rule is the last you will read. Redirect now !

Here is the documentation.

In my case, all the connection made to http://www.software-crafting.com will automatically be redirected to http://www.software-crafting.com/blog.