1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Pointing a subdomain to a subdirectory on another host?

Discussion in 'Computers, Games, Electronics etc' started by DarkHand, Nov 14, 2011.

  1. DarkHand

    DarkHand Senior Member

    Joined:
    Sep 30, 2002
    Messages:
    5,095
    Media:
    2
    Likes Received:
    230
    Location:
    Chicago, IL
    Ok, so I have my domain hosted at Godaddy with a crappy $5/month plan. It's not bad for small usage... 'unlimited' bandwidth, 10GB space. I use it for file storage (minecraft server backup archives) and the free phpbb forum.

    I also have a minecraft server hosted with Bitcable, 8-core 3.2ghz KVM, 4gb ram, 200GB raid, 2.4TB transfer/month on a gigabit link. Right now I have an A-record on the godaddy domain pointing to it (mc.domain.com) so I have a nice clean subdomain for folks to type in.

    I'm also running Dynmap, which provides realtime mapping of the minecraft server. That's in a subdirectory on the bitcable boxes webserver.

    I'd like to create another subdomain and have it point to the mapping directory on the bitcable box (map.domain.com). How can I get a subdomain to point to a subdirectory on a remote box?

    Yes I should probably ditch the $5 plan and put it all on the bitcable box, but meh.

    EDIT: Typing this all out helped me think through it a bit... I'm guessing I need some sort of .htaccess tomfoolery to redirect connections that have the Map subdomain as a referrer, but maybe there's a better way?
    Last edited: Nov 14, 2011
  2. Briansol

    Briansol Admins Admin

    Joined:
    Nov 18, 2007
    Messages:
    19,297
    Media:
    29
    Albums:
    2
    Likes Received:
    1,220
    Location:
    CT
    Why not just create a CNAME record for the 2nd subdomain?

    that's basically what i'm doing here for the CDN. all the js.hondaswap.biz urls are actually loading myaccount.myprofile.mycdnprovider.com/
  3. B16

    B16 Super Moderator

    Joined:
    Sep 30, 2002
    Messages:
    11,021
    Likes Received:
    232
    Location:
    yay area, CA
    Agreed, use a CNAME.

    and what do you mean point to a sub directory? like have newname.domain.com -> whatever.host.net/subdirectory?
  4. reikoshea

    reikoshea HS Troll...And Mod Moderator

    Joined:
    Apr 27, 2005
    Messages:
    12,579
    Likes Received:
    159
    Location:
    Dallas, TX
    The subdomain part can be kind of confusing, but if you add this to your htaccess file for your primary domain on the box you're pointing the other site to. it'll do what you want. It wont work until after you've added the CNAME for your other site.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.domain.com$
    RewriteRule ^(.*)$ /DIRECTORY/$1
  5. Briansol

    Briansol Admins Admin

    Joined:
    Nov 18, 2007
    Messages:
    19,297
    Media:
    29
    Albums:
    2
    Likes Received:
    1,220
    Location:
    CT
    RewriteCond %{HTTP_HOST} ^www.domain.com$
    should be
    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$

    to escape and allow for non-www as well
  6. reikoshea

    reikoshea HS Troll...And Mod Moderator

    Joined:
    Apr 27, 2005
    Messages:
    12,579
    Likes Received:
    159
    Location:
    Dallas, TX
    well it's likely not going to be a www, i wrote that in 10 seconds to fill the requirements he gave. Im supposed to be at work at 10am central...i posted that at 9:42.

    Feel the love darkhand.

Share This Page