how do I change the url based on a theme? On some occasions, I've seen Drupal able to detect things like language and rewrite the url accordingly, so your actual displayed url reflects the detected value (like from http://www.mysite.com/foo/bar to http://www.mysite.com/en/foo/bar)

I want to do that based on the $theme_key. I want all the data, when displayed in the 'fancytheme' theme, rewritten from  http://www.mysite.com/foo/bar to http://fancytheme.mysite.com/foo/bar


is that possible ? 
how would i go about ?
is there a module out there that already does that ?
Normally, you could accomplish this with URL rewrite rules or theme switching modules like ThemeKey but you're moving to a different sub-domain which Drupal is going to assume is a new database. The best way to do this then is to use the Domain Access module to simulate the use of a sub-domain without switching your database. 

Domain Access is a little trickier to setup (read the install file carefully) but it allows separate themes for each subdomain with the "Domain Theme" module.


  Domain Theme -- Allows separate themes, theme settings and colors for
  each subdomain.