• Blogging
  • Monetizing
  • Social Media
  • Marketing
  • Plugins
  • Resources

Blog a Living

Tales of a Full-Time Blogger

Redirect a subdomain to totally different URL

(This post may contain affiliate links. Please read our disclosure.)

Redirect a subdomain to totally different URLHtaccess 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.

TwitterFacebookPinterestEmailReddit

Related Posts

  • Making commenters work for you: going beyond simple moderation
  • Making commenters work for you: beyond deleting and modding
  • Why working for free doesn’t work
  • Working with Personas

Filed Under: Blogging Tagged With: Coding, Htaccess

Comments

    Leave a Reply Cancel reply

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

  1. Genghis says

    October 22, 2011 at 6:20 am

    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 http://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

    Reply
  2. Chris says

    October 22, 2011 at 9:25 am

    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.

    Reply

Get Email Notifications

If you want to be notified of every new BlogALiving post, subscribe on BlogLovin’!

Cool Stuff

After a buggy update blew up my websites, I decided to replace Social Warfare. Learn which plugins I used - and how they gave me a nice little traffic bump for speeding up my site.

Plugins to Replace Social Warfare

Stylized letter with email symbol sticking out of an envelope

Why I Don’t Have an Email List

At first I loved GetResponse. Then they dropped phone support. Then they flagged my account and froze it for no reason, and they won’t tell me why. Read more about my disappointing experience with this much-loved company.

Why I Decided Against GetResponse

The Theme I Use

I use Genesis on all my sites. I've tried a lot of free themes, ThemeForest themes and DIY (Thesis), and Genesis wins hands down.
StudioPress Sites

My favorite Host & Analytics

  • TigerTech Hosting and Domain Registration
  • Clicky Web Analytics

My anti-virus

If your PC gets infected, your website can become infected, too. Don't let it happen! My PCs run:

  • Emsisoft - great AV and firewall suite
  • Malwarebytes - designed to run along with other AV software
  • CryptoPrevent - a small program that blocks ransomware. Read more here: Cryptowall: how to protect your PC
  • Facebook
  • Twitter
  • Pinterest
  • Bloglovin

© 2005–2019 BlogALiving.com – About – Terms of Use – Contact – Privacy – Disclosure

BlogALiving is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites..

  • Facebook
  • Twitter
  • Pinterest
  • Bloglovin
  • Recommended Blogger Resources
  • Blogging
  • Plugins
  • Marketing
  • Monetizing
  • Social Media
  • Email Marketing
  • About
  • Privacy
  • Disclosure
  • Terms of Use
  • Contact
  • Advertise
We use cookies to give you the best experience on our website. OkRead more