Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Bostonaholic

macrumors 6502
Original poster
Aug 21, 2009
439
0
Columbus, Ohio
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.
 
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 here, i.e. main 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
 
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 here, i.e. main 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

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>
 
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
 
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

It does, thank you very much.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.