Yet Another Blog by Nitesh Mistry

Entries tagged "apache"

Redirecting to Other Website
13th November 2010

Yesterday, I gave this blog a website of its own. So now its address is instead of old Creating a new site was very simple. As simple as opening a new email account, rather even more. With just 3 - 4 clicks, this blog had its spanking new website ready to shift in. Then it was just a matter of moving my blog contents to this new website and telling my DNS manager about its new address (follow this space on how did I get a new website and manage DNS). Also, getting a new website is as good as free because my webhost - NFSN - charges me only for the actual storage space and bandwidth used. So it is practically same as just transferring data to a new directory since my website is completely static.

So far so good. And then it hit me! What about the readers who are already following my blog? If they visit my old address, they will get 'Page Not Found' error. All those who have subscribed to my RSS feeds will no longer get the updates. Keeping the same content at both the places is not such an elegant solution. Neither does it do any good to search engine friendliness. So, how do I make the old visitors (who might directly visit my old address) go automatically to the new address?

".htaccess" To the Rescue!
Well, as I found out, there was no need to worry. If your webhost is using Apache webserver, this is just a two minute job. Apache webserver system provides a simple way to redirect a visitor to another website using a redirect directive in a .htaccess file. Oooo, sounds too geeky! Don't worry, it just sounds geeky. Actually you only have to create and save a file. So, create a text file named ".htaccess" and put the following line in that file

RedirectPermanent <old address> <new address>
For example, in my case the line was RedirectPermanent /blog (I did not need to write the old address completely; just the part which needs redirect). Save the file and close it. Now put this file in your public directory of webserver and you are good to go.

If you are even half as geeky as I am, you will definitely want to test this. So in your web-browser, type the old address and whoa, it automatically takes you to the new address! Another nice little thing I liked about this is, all the extra words and characters that are suffixed to the old address are automatically suffixed to the new address as well. Just to give you and example, I have a tag named 'linux' in my blog so to access it, the old address was which after putting this redirect, automatically goes to And this applies to every link in the 'blog' directory.

Neat, isn't it?

Email comments to Nitesh Mistry   Tags: apache, geekosophy, howto, htaccess, redirect, website.