So there’s two issues here: those who come in on new.com must only see new.com, but the underlying reading/writing still deals with mysite.com. Secondly, those who come in from an old link must see the same page but see new.com in the address bar.

If its physical, ie /home/username/mysite.com/section/somepage.rb, then you could specify the directory as the web directory for new.com, then just have to re-write the filename if necessary.

Secondly, those who come in from an old link must see the same page but see new.com in the address bar.

If the above works for you, then you could redirect to new.com based on the HTTP_HOST header.

I don’t do any RoR programming yet, so don’t know why you can just deploy whatever mysite.com/section did into the web directory for new.com instead. Do the domains have different FTP/CGI runs-as users?

Thanks for the feedback. We basically have two domains that point to the same user account on Dreamhost (ie. the same physical directory, if I understand correctly).

Uh, not exactly what I was talking about.

DreamHost uses named-based virtual hosting. The browser connects to the DreamHost machine and tells the machine what hostname it is trying to visit. This is provided in the “Host” header of the requuest and becomes available on the machine as the HTTP_HOST environment variable.

HTTP requests also include a url-path. This is the part of the URI after the hostname (included the slash) but not the fragment or query string. eg http://example.com/index.php?page=home, the url-path here is /index.php

Now when a request comes into the Apache, it goes through the server configuration looking for special rules to apply to certain uri-paths. It will then traverse the filesystem for .htaccess files with special rules too (this is where mod_rewrite comes in). If no special rules apply, it translates the url-path to a filesystem path and attempts to access that directory or file (what I meant as ‘physical’) This file system path will be relative to the “document root” (DreamHost calls it the web directory" ie http://example.com/index.php gets mapped to /home/username/example.com/index.php given a web directory of /home/username/example.com

By ‘virtual’ I meant the ‘search engine friendly’ urls the like that are ‘special’, eg the url-path /show/picture/1 gets converted to a call to /index.php?action=show&category=picture&item=1 (which might be the cases if the url is handled by RoR apps too)

There are two different methods, two different words: redirect and rewrite. A redirect tells the browser to go to a different url. So that is what you need to ask for when you want the “address bar to change.” A rewrite is where Apache changes the value and uses the new value instead - it doesn’t have to tell the browser the value changed - so the “address bar does not change”.

To pull this off, I redirected habanerolabs.com to chillisoft.co.za/habanero and do the rewrite after that. In my understanding that will work for both people coming in through the new URL and those with links to the old site.

My .htaccess as follows is a little bit messy and a little bit fragile, due to the main site being RubyOnRails and exceptions being added for the PHP pages. Currently everything is working fine except the rewrite is not happening:

To pull this off, I redirected habanerolabs.com to chillisoft.co.za/habanero and do the rewrite after that. In my understanding that will work for both people coming in through the new URL and those with links to the old site.[/quote]
I’m sorry, but let’s clarify what you want to happen without being so simplistic.

In case you don’t know this already it needs to be pointed at that you can’t rewrite the hostname. So if you want the hostname to change, you have to have a redirect from the old hostname to the new hostname. This means the browser will always change the URL in the address bar too.

So if you want to do what you said in your original post, you need to do a couple of things.

Setup habanerolabs.com as a fully-hosted domain with a web directory of /home/username/chillisoft.co.za/habanero/

You have started off on a different track instead, so please advise which track you want to follow.

Reference: An HTTP URL is scheme://hostname/url-path

Rewriting changes the url-path internally. This is what must happen for RoR to work or to make search engine-friendly URLs for example. You can rewrite the url-path when changing the hostname too, but because the hostname changed the browser will change the URL in the address bar showing both changes.