#1
  1. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539

    Domain.com and www.domain.com


    Hello, I have my first VPS, so I could do more than I previously did. I found I could create virtual servers (I'm doing the name version opposed to the IP version). Am I better off creating multiple virtual servers for domain.com and www.domain.com, or using something like .htaccess? If the later, should I use .htaccess, httpd.conf, mod_alias, or something else? Thank you
    Last edited by NotionCommotion; March 10th, 2011 at 04:17 PM.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7175
    Usually I have both configured to point to the same document root and use mod_rewrite to redirect domain.com to www.domain.com.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539
    Usually I have both configured to point to the same document root
    I'm missing something. What do you use to point them to the same root?
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7175
    No reason in particular, just convenience.

    Comments on this post

    • ryon420 agrees : Why are you a moderator and I'm not!?
    • requinix agrees : ^ made me laugh
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539
    No, not "why" to you point them to the same root, but "how" do you point them to the same root?

    Say I want domains mydomain.com and www.mydomain.com to both point to /var/www/mydomain/html.

    I could use Apache to create a virtual server for each domain, and point them each to /var/www/mydomain/html. Is this what you mean by "Usually I have both configured to point to the same document root"?

    But if I do this, why do I bother using mod_rewrite and redirecting one of them?

    As I said, I must be missing something...
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7175
    Sorry, it was 8:30 in the morning. I use the ServerAlias directive. Just one vhost record, but it's ServerAlias'd to the second domain too.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo