How do I put a blog on http://blog.whatever.com

Discussion in 'Web Design and Development' started by Bostonaholic, Oct 22, 2009.

  1. Bostonaholic macrumors 6502

    Bostonaholic

    Joined:
    Aug 21, 2009
    Location:
    Columbus, Ohio
    #1
    I have my personal website http://www.matthewboston.com but how would I put my blog as http://blog.matthewboston.com?

    GoDaddy is currently hosting my site so maybe it's not possible now, but I plan to host it locally. Setting it up now, my Apache webserver is running on ~/Sites/matthewboston/www/

    Would it be as simple as directing Apache to point to ~/Sites/matthewboston/ then have a www/ and blog/ underneath?

    Thanks.
     
  2. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    Is the blog a page within the site, or a separate site?

    BTW, answer as to what you want, ultimately, not the way it might be now.

    If the former, here's an effective way:

    Tell GoDaddy or setup your own domain file so "blog" is CNAME for matthewboston.com. Then setup Apache with "blog.matthewboston.com" as an alias or ServerName in your config - this is up to you to know how to do as Apache can be configured in different ways, i.e. globally or virtual subhosts. Then all the URL's you mentioned will take users to your main page but you can add a condition at the top of your source code to check for "blog" in the URL, i.e. in PHP:

    PHP:
    if (preg_match("/blog./i",$_SERVER['HTTP_HOST'])) { ... blog stuff here ... }
    else { .... 
    none blog stuff herei.emain page ... }
    Simple, no redirects and issues with SEO, server side parsed so no reliance on client side scripting, and you control what happens without having to adjust the DNS if you make a change in script or paths in the future. You might see others providing you HTML or source code to redirect, which is fine, but think of my advice more as template parsing - it's a nice approach. Sure, not the only one.

    If the latter:

    You'll need to explain where it's hosted before I can answer. If you setup another virtual host vs. it's on a completely different server, etc.

    -jim
     
  3. Bostonaholic thread starter macrumors 6502

    Bostonaholic

    Joined:
    Aug 21, 2009
    Location:
    Columbus, Ohio
    #3
    Thank you. I did a simple Google search for 'Apache CNAME' and I think I got the jist of it.

    If I set it up as a VirtualHost like such, will it work?
    Code:
     <VirtualHost *:80>
        DocumentRoot Sites/matthewboston/www
        ServerName www.matthewboston.com
        ...
        </VirtualHost>
        
        <VirtualHost *:80>
        DocumentRoot Sites/matthewboston/blog
        ServerName blog.matthewboston.com
        ...
        </VirtualHost>
     
  4. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #4
    Looking good, that tells me your blog source is in a different path than your main site, i.e. like two different sites.

    The CNAME stuff is part of the DNS setup for your domain, has nothing to do with Apache. That tells the world to find your server, then when a user hits your server Apache then determines which document root to use based on the hostname and serves the proper files. Simple as that.

    To edit the DNS zone file that's usually handled at the registrar's web site where you registered the domain, but it could be at the webhost's site too if you bundled webhosting/domain registration. Hope this helps avoid confusion about the CNAME stuff.

    -jim
     
  5. Bostonaholic thread starter macrumors 6502

    Bostonaholic

    Joined:
    Aug 21, 2009
    Location:
    Columbus, Ohio
    #5
    It does, thank you very much.
     

Share This Page