Redirect a subdomain to totally different URL

Htaccess redirecting is a powerful and somewhat frightening tool. After all, one typo and your domain is pointing nowhere in an infinite loop. It’s okay, though, because you can always get back in through FTP or Cpanel to fix it. As long as you kept a backup copy before making your changes. And that’s exactly what you need to do before following any of the instructions in this post. Back that sucker right up!

If you want to redirect one domain to another, that’s pretty simple, right? You just put code like this into the .htaccess file of the domain you’re redirecting:
Redirect 301 / http://olddomain.com/
But what if you want to redirect a subdomain from one URL to a totally different URL? Let’s say you’ve been writing a blog on a subdirectory of a site, and you’ve decided that subdirectory needs its own domain. Your current blog is at:
http://blog.olddomain.com/
And you want to redirect it to:
http://newdomain.com/
What can you possibly put in your htaccess to make that happen? Nothing. Except… well, the big trick is to put it in the .htaccess under the subdomain’s main folder. So, inside your “blog” subdomain on the old domain, you would put this code:
redirect 301 / http://newdomain.com/
It’s exactly the same as the code above – the only difference is which .htaccess file you put it in.

This also works well for redirecting Feedburner MyBrand feeds to new URLs. For example, go to your Feeds subfolder at olddomain.com, and in the htaccess for it, put:
redirect 301 / http://feeds.newdomain.com/newdomain
That redirects any address starting with “feeds.olddomain.com” to the exact MyBrand URL for your new Feedburner feed.

Enjoy the post? Why not share it?

Last Updated:

August 26, 2021

More Like This