Welcome Guest | Login

Routing 'www' to another website

Hi,

I have a rails application running on an addon domain and it uses subdomains to key parts of the application.  We will also be running a static/php website under the same domain and we'd like to have http://www.domain.com & http://domain.com point to this static website and have all the rest of the subdomains route to the app, like it does now.  How would I do this routing?  Is it possible?  Thanks

2008-01-25 09:45 AM

You want the main domain to have  the static/php site and the addon domain to have the rails application right? It that case it will work fine.

2008-01-25 05:05 PM

Regards,
Rahul
Well, no.  We want to have the static/php site at http://www.domain.com' and http://domain.com' and have all of the sub-domains of the same domain route to the application, like http://sub.domain.com'.  Both of these cases will use the same domain, either the main domain or an addon.  Does this make sense?

2008-01-28 08:15 AM

You would setup a rewrite rule so that all subdomains get captured into a parameter that you could pass to an action

RewriteCond %{http_host} !^www\.
RewriteCond %{http_host} ^(.+)\.domain\.com
RewriteRule ^(.*) /controller/action/%1/$1 [L]

the $1 would be the URL string so you could pass that along as well.



2008-01-28 03:50 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!