# Virtual Domains 0.6 Routing problems

**URL:** <https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573>\
**Category:** Radiant CMS\
**Created:** [April 20, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573 "2007-04-20T22:55:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 20, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/1 "2007-04-20T22:55:48Z")

</div>

I’m having trouble using virtual domains 0.6. I believe that is the  
version that has been updated for the radiant .6 candidate. I am able to  
specify the slug of a default page that I want any requests forwarded to  
the radiant installation to go to. However nothing else seems to work.  
Upon inserting a debugging block of code in the installation and running  
all sorts of inspections on the “@hostname ||=  
Page.request.respond\_to?(:host) ? Page.request.host : nil” it always  
returns nil. @hostname is always nil

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 20, 2007, 11:19pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/2 "2007-04-20T23:19:09Z")

</div>

On Apr 20, 2007, at 4:55 PM, Mathieu Lue wrote:

> returns nil. @hostname is always nil  
> Is Page.request set to anything? If not, it means that the  
> CacheByDomain module isn’t being loaded properly, or the show\_page  
> method is being overridden by something else.

If it is, then the request doesn’t have any host information which is  
just odd.

~~ Brian

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 21, 2007, 3:24pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/3 "2007-04-21T15:24:09Z")

</div>

Hi,

I had the same problem when I installed virtual domain extension (ver.  
1.1) some days ago. I solved it by this patch.

— virtual\_domain\_extension.rb.orig 2007-04-21 21:28:32.000000000  
+0900  
+++ virtual\_domain\_extension.rb 2007-04-21 21:37:23.000000000 +0900  
@@ -8,7 +8,13 @@  
def activate  
Page.send :mattr\_accessor, :request  
require\_dependency ‘application’

- SiteController.send :alias\_method, :show\_page\_orig, :show\_page
- SiteController.send :remove\_method, :show\_page  
SiteController.send :include, CacheByDomain  
VirtualDomainPage  
end
- 
- def deactivate
- SiteController.send :alias\_method, :show\_page, :show\_page\_orig
- end  
end

This removes the method SiteController#show\_page before SiteController  
includes CacheByDomain, because Ruby’s Mix-in is realised by inserting  
a module into class inheritance relation.(SiteController \>  
CacheByDomain \> ApplicationController \> …) I think @hostname is  
always nil when SiteController#show\_page is not removed.(because  
CacheByDomain#show\_page is not called but original  
SiteController#show\_page, and Page.request is setted by  
CacheByDomain#show\_page) This patch works fine in my environment.

* * *

Keita Y.

2007/4/21, Brian G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 21, 2007, 3:39pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/4 "2007-04-21T15:39:12Z")

</div>

On Apr 21, 2007, at 9:23 AM, keita wrote:

> Hi,
> 
> I had the same problem when I installed virtual domain extension (ver.  
> 1.1) some days ago. I solved it by this patch.

Thank you very much. I will apply this patch and put out 1.2, which  
should be available soon at:

[http://silverinsanity.com/~benji/radiant/virtual\_domain-1.2.tar.gz](http://silverinsanity.com/~benji/radiant/virtual_domain-1.2.tar.gz)

~~ Brian

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 21, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/5 "2007-04-21T17:49:27Z")

</div>

Sorry, I forgot remove the method SiteController#show\_uncached\_page.

— virtual\_domain\_extension.rb.orig 2007-04-22 00:34:57.000000000  
+0900  
+++ virtual\_domain\_extension.rb 2007-04-22 00:43:58.000000000 +0900  
@@ -10,12 +10,15 @@  
Page.send :mattr\_accessor, :request  
require\_dependency ‘application’  
SiteController.send :alias\_method, :show\_page\_orig, :show\_page

- SiteController.send :alias\_method, :show\_uncached\_page\_orig,  
:show\_uncached\_page  
SiteController.send :remove\_method, :show\_page
- SiteController.send :remove\_method, :show\_uncached\_page  
SiteController.send :include, CacheByDomain  
VirtualDomainPage  
end

def deactivate  
SiteController.send :alias\_method, :show\_page, :show\_page\_orig

- SiteController.send :alias\_method, :show\_uncached\_page,  
:show\_uncached\_page\_orig  
end  
end

* * *

Keita Y.

2007/4/21, Brian G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 21, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/6 "2007-04-21T18:41:46Z")

</div>

Thanks alot guys. 1.2.1 works like a breeze. The only question I have no  
is that since the “:” character is used to delimit the domain name from  
the slug, is there anyway to forward domains with a specified port? I  
tried [x.y.com:3003](http://x.y.com:3003): and it didn’t work. I totally don’t need this  
functionality but I was just curious.

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 21, 2007, 8:32pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/7 "2007-04-21T20:32:44Z")

</div>

On Apr 21, 2007, at 12:41 PM, Mathieu Lue wrote:

> Thanks alot guys. 1.2.1 works like a breeze. The only question I  
> have no  
> is that since the “:” character is used to delimit the domain name  
> from  
> the slug, is there anyway to forward domains with a specified port? I  
> tried [x.y.com:3003](http://x.y.com:3003): and it didn’t work. I totally don’t need  
> this  
> functionality but I was just curious.

As written, it only distinguishes based on the host and completely  
ignores the port. So, if you only have one Radiant instance on  
[x.y.com](http://x.y.com), then it doesn’t matter what port. If you want [x.y.com:3003](http://x.y.com:3003)  
and [x.y.com:80](http://x.y.com:80) to be different “domains”, you’ll need to poke through  
the code to change request.host to request.host\_with\_port.

And to add it to the YAML config, you’d do something like:

“[x.y.com:3003](http://x.y.com:3003)” : slug1

~~ Brian

---

<div class="post-metadata">

**Author:** ![mlue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@mlue](https://www.ruby-forum.com/u/mlue)\
**Post date:** [April 21, 2007, 5:58pm UTC](https://www.ruby-forum.com/t/virtual-domains-0-6-routing-problems/92573/8 "2007-04-21T17:58:28Z")

</div>

On Apr 21, 2007, at 11:48 AM, keita wrote:

> Sorry, I forgot remove the method SiteController#show\_uncached\_page.

I should have caught that myself. 1.2.1 will appear soon.

~~ Brian
