PDA

View Full Version : .htaccess rules to load a different directory for a domain.


kb0kqa
04-20-2008, 04:14 PM
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.

Justec
04-20-2008, 05:44 PM
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.

kb0kqa
04-20-2008, 06:53 PM
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).

Justec
04-20-2008, 07:21 PM
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.

kb0kqa
04-20-2008, 07:27 PM
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!

seeseeya
05-01-2008, 06:46 PM
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.

kb0kqa
05-05-2008, 10:18 PM
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.

ManagerJosh
05-06-2008, 02:22 AM
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 ?

kb0kqa
05-06-2008, 04:28 PM
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.

Kevin
05-07-2008, 01:31 PM
Adding one domain as a Domain Alias to the other domain's "Domain" page would do what Josh described.

kb0kqa
05-07-2008, 06:41 PM
Adding one domain as a Domain Alias to the other domain's "Domain" page would do what Josh described.

Ok, got that to work I think (I tried it on one of my domains and it seems to work good).

Now we'll see what new questions it brings up.

Thanks!