Skip to Content

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.

Chris

Saturday 22nd of October 2011

Well, I tried to visit your subdomain to see what was happening, and got a warning that Wordpress was missing its config file, so I can't really see what it's doing wrong. If you could look into that and get back to me, I could see exactly what the link is doing and maybe have a better sense of what the problem is.

Brian Brown, Ph.D.

Sunday 19th of September 2021

Genghis has: .com.com ? RewriteRule ^.*$ http://www.being-free.com.com/book-store [R=30]

Also, Google Feedburner has deprecated "MyBrand" and just about everything else that it used to offer. I'm sure that they would like to get rid of it completely as its not making them money. They're all about money now that they're publicly traded and the bankers and their minions are running things. Best to NOT do a 301 redirect to them; do a 302 (temporary) instead. (In case anybody surfs in here.) -Brian

Genghis

Saturday 22nd of October 2011

Hi Chris, I have a main site running Joomla 1.5.23 and a subdomain hanging off it running Wordpress 3.2.1.

The subdomain which I am currently setting up displays a blog and book store.

The subdomain is www.being-free.com/book-store.

One of the menu options on the subdomain has a link which takes you back to the main site which worked absolutely fine until I set up FeedBurner. Since then when I take this link it takes me to my feed burner feeds!

My original .htaccess file looked like this:

RewriteEngine On RewriteRule ^.*$ http://www.being-free.com.com/book-store [R=301]

# Switch rewrite engine off in case this was installed under HostPay. RewriteEngine Off

SetEnv DEFAULT_PHP_VERSION 5

# BEGIN WordPress DirectoryIndex index.cgi index.php

RewriteEngine On RewriteBase /book-store/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /book-store/index.php [L]

# END WordPress

I then added the following for Feedburner so it looked like this:

RewriteEngine On RewriteRule ^.*$ http://www.being-free.com.com/book-store [R=301]

# Switch rewrite engine off in case this was installed under HostPay. RewriteEngine Off # temp redirect wordpress content feeds to feedburner

RewriteEngine on RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC] RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC] RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/BeingFreeBlogBookStore [R=302,NC,L]

# temp redirect wordpress comment feeds to feedburner

RewriteEngine on RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC] RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC] RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/BeingFreeBlogBookStore [R=302,NC,L]

Is there way I can create a rewrite to ensure the link back to my site works with feedburner?

Regards Genghis