How to redirect every single visitor to a different directory like hongkiat.com
I had my website on http://rohbits.com but I had to delete it completely and create a new one in http://www.rohbits.com/blog. I have redirected all the traffic that is sent to rohbits.com to www.rohbits.com/blog but when anyone visit rohbits.com/blah-blah-blah, it takes them to a 404 error page provided by the hosting service which in my case is hostgators. I have been searching for a answer for a long time and then one day I visited a blog (www.hongkiat.com/blog) who have their blog directory similar to mine and after some research I found out that, www.hongkiat.com/blog, was initially hongkiat.com and after one year they have shifted it to different directory.
Whenever I go to hongkiat.com, I get redirected to www.hongkiat.com/blog and when I type something like this after the link hongkiat.com/blah-blah-blah, it still gets redirected to www.hongkiat.com/blog. Someone told me the other day that "This will only work if you have the same post on the new directory" but i don't think that hongkiat.com had any post like this one hongkiat.com/blah-blah-blah.
How have you redirected trafic from rohbits.com to www.rohbits.com/blog?
If you have used a .htaccess file, it's easy to do what you want
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %HTTP_HOST ^rohbits.com[nc]
RewriteRule ^(.*)$ http://www.rohbits.com/ [r=301,nc]
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Comments
Post a Comment