Technology

Apache Redirect 301

I have 2 domains now since I acquired www.ridvanbaluyos.com. I was using the ridvan.baluyos.net for almost 6 years now and has been riding on to my brother’s hosting. I just thought it was about time I buy my own and go on independent.

My older domain (or subdomain) has more hits and is getting crawled by Google frequently rather than my old one. And the thing is, my old domain is also pointing to the same server. My SEO expert friend and officemate, Almer Viloria (he’s really good), advised me to put a 301 permanent redirect on my older domain to prevent any penalty from Google regarding a duplicate (I still don’t know what that means). I tried the .htaccess method but was not successful. I tried several formats and configs but for almost a week I failed. Only then now, around 3:30am in the morning, I found the solution. It was from a tutorial blog in DigitalOcean, which apparently is my dedicated cloud hosting, that I found the answer. It says that if you already have access to your Apache config, then there is no need for the .htaccess method.

I tried it and it redirected!

My simple config goes something like this:

<VirtualHost *:80>
ServerName ridvan.baluyos.com
Redirect 301 / http://www.ridvanbaluyos.com
</VirtualHost>

<VirtualHost *:80>
ServerName www.ridvanbaluyos.com
ServerAdmin [email protected]

</VirtualHost>

Take note though that the ServerName must be present in both tags otherwise it would cause you a redirect loop.

So there, my old domain (http://ridvan.baluyos.net) is now being redirected to my new one (http://www.ridvanbaluyos.com).

Leave a Reply

Your email address will not be published. Required fields are marked *

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