+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: .htaccess rules to load a different directory for a domain.

  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    36

    Default .htaccess rules to load a different directory for a domain.

    This came up in a discussion with another member. I've tried Google but didn't find the answers I was looking for.

    Say I have a domain, abc.com. Say I also have a domain, def.com.

    I want it so that they both load the code from abc.com's directory (ie. the def.com directory is basically empty). However, I don't want to redirect def.com to abc.com - if the user browses to def.com/index.html then their browser should say def.com/index.html, not abc.com/index.html.

    Right now I've done it by removing the directory for def.com and creating a symlink to point to abc.com. The problem with that is that it breaks the webalizer.

    I'm sure there's a cleaner way to do it via .htaccess although I'm not sure what that is.

  2. #2
    Happy Steadfast Client
    Join Date
    Jan 2006
    Location
    Miami, Fl
    Posts
    125

    Default

    This is usually a bad idea if you have any interest in being ranked by google an others. You get negative points for having the same content on 2 different sites.

    Not sure if you can do it via htaccess or not, but i think changing the document root to point to the same place for both sites would be the way to go.
    [ JUSTIN ]
    [ justechnology llc ]
    [ WEB DESIGN / DEVELOPMENT, TECHNICAL CONSULTING, & BUSINESS WEB HOSTING
    ]
    [ when will apple? ]
    [ GUESS THE RELEASE DATE AND GET THE SCOOP ON APPLE'S NEW PRODUCTS
    ]

  3. #3
    Member
    Join Date
    Jan 2008
    Posts
    36

    Default

    Quote Originally Posted by Justec View Post
    This is usually a bad idea if you have any interest in being ranked by google an others. You get negative points for having the same content on 2 different sites.

    Not sure if you can do it via htaccess or not, but i think changing the document root to point to the same place for both sites would be the way to go.
    I'm not worried about the ranking (the content is served by Drupal, which is configured differently for the two sites, so the content is actually totally different for each site).

    The problem with changing the document root (I assume that you're referring to the way that I have already done it) is that it breaks the webalizer for the sites that are symlinked. I'm not sure if it is giving incorrect stats for the site that actually contains the code or not (I've not really investigated that).

  4. #4
    Happy Steadfast Client
    Join Date
    Jan 2006
    Location
    Miami, Fl
    Posts
    125

    Default

    Not sure how you can have different content unless the content is being pulled out of two different databases? But then not sure why you would want to share the same directory?

    What you did was a symlink, I was saying to change the path in the apache vhost file. Not sure if this method will work with stats better than your symlink method or not, but the stats should be kept separate either way unless you symlink the entire directory instead of just the "public_html" path.
    [ JUSTIN ]
    [ justechnology llc ]
    [ WEB DESIGN / DEVELOPMENT, TECHNICAL CONSULTING, & BUSINESS WEB HOSTING
    ]
    [ when will apple? ]
    [ GUESS THE RELEASE DATE AND GET THE SCOOP ON APPLE'S NEW PRODUCTS
    ]

  5. #5
    Member
    Join Date
    Jan 2008
    Posts
    36

    Default

    Quote Originally Posted by Justec View Post
    Not sure how you can have different content unless the content is being pulled out of two different databases? But then not sure why you would want to share the same directory?
    The content is pulled from two different dbs. Drupal checks to see what the url is and builds the page appropriately based on how it's configured. The two sites are totally different but share a php codebase.

    The purpose of doing it this way is that you can now run multiple Drupal sites, but you only have one copy of the code (less disk space, less maintenance headaches when you upgrade/update).

    What you did was a symlink, I was saying to change the path in the apache vhost file. Not sure if this method will work with stats better than your symlink method or not, but the stats should be kept separate either way unless you symlink the entire directory instead of just the "public_html" path.
    How do I update the vhost file then?

    I do symlink the entire directory - I'm open to suggestions otherwise.

    Here's what I have:

    /hsphere/local/home/user/abc.com which has the content such as
    /hsphere/local/home/user/abc.com/index.html

    and /hsphere/local/home/user/def.com which points to (using a symlink) /hsphere/local/home/user/abc.com

    I'm not sure what you're referring to when you talk about the public_html path as to me that's what I'm already doing.

    Thanks!

  6. #6
    Junior Member
    Join Date
    Sep 2007
    Posts
    3

    Default

    Try to use H-sphere,
    There's a Domains -> control (edit setting) -> Web service edit.
    You can set Server Alias there.
    It might be help for you.

  7. #7
    Member
    Join Date
    Jan 2008
    Posts
    36

    Default

    Quote Originally Posted by seeseeya View Post
    Try to use H-sphere,
    There's a Domains -> control (edit setting) -> Web service edit.
    You can set Server Alias there.
    It might be help for you.
    Thanks for the reply.

    That doesn't allow me to change the directory that it loads however.

    In the Edit Domains screen there is a field called "HTML Directory Name", but it's not editable.

  8. #8
    Moderator
    Join Date
    Mar 2007
    Location
    Southern California
    Posts
    150

    Default

    I presume your objective is to do something like


    domaina.com and domainb.com but they point to the exact same content, but appear as different sites without domainb.com forwarding everything to domaina.com ?
    All the best,
    ManagerJosh
    Gaming Hosting Director of
    SimGames.net, Owned and Operated by Steadfast Networks

  9. #9
    Member
    Join Date
    Jan 2008
    Posts
    36

    Default

    Quote Originally Posted by ManagerJosh View Post
    I presume your objective is to do something like


    domaina.com and domainb.com but they point to the exact same content, but appear as different sites without domainb.com forwarding everything to domaina.com ?
    Yes, that would be accurate.

  10. #10
    I love LAMP.
    Join Date
    Jul 2004
    Location
    Chicago, Illinois, United States
    Posts
    201

    Default

    Adding one domain as a Domain Alias to the other domain's "Domain" page would do what Josh described.
    Kevin Stange
    Chief Technology Officer
    Steadfast Networks
    http://steadfast.net
    kevin@steadfast.net

+ Reply to Thread
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts