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
Routing 'www' to another website
- Redpost
- Posts: 4
- Starts: 4
- Wiki Edits: 0
- Location: Goshen, Ind.
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
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
- Rahul
- Posts: 509
- Starts: 0
- Wiki Edits: 1
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
- Redpost
- Posts: 4
- Starts: 4
- Wiki Edits: 0
- Location: Goshen, Ind.
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
- William
- Posts: 1062
- Starts: 32
- Wiki Edits: 56
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.
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.