Forum OpenACS Q&A: subsites...

Collapse
Posted by David Kuczek on
What would I have to do to get a site running which is accessed by
subsite.mysite.com and not www.mysite.com?

On subsite.mysite.com everything but the header and the footer should
be the same as on www.mysite.com!

Collapse
2: Response to subsites... (response to 1)
Posted by Don Baccus on
Check out the host-node map stuff.  This lets you point an arbitrary host to an arbitrary subsite.

Then check out acs-subsite.  This has a default master template and also calls the site master.  For a simple customization such as you're discussing setting the header/footer info in the subsite default.tcl template adn passing them as properties to the site master would work.  Of course the site master would then create header/footer info unless it already existed.

Collapse
3: Response to subsites... (response to 1)
Posted by David Kuczek on
I am running 3.2.5 but where do I find host-node map?

I saw a subsite package and host-node-map inside oacs 4.5...

Collapse
4: Response to subsites... (response to 1)
Posted by Tilmann Singer on
host-node-map is part of the acs-subsite package, which is part of oacs 4.5. I don't know of a comparable functionality in oacs 3.x, but if it is only the header and footer that you want to change then it should be quite easy to modify the ad_header and ad_footer procs (if you are not using the templating stuff) by adding a check for the value of [ns_conn host].
Collapse
5: Response to subsites... (response to 1)
Posted by David Kuczek on
Hello Tilmann,

this sounds good... What would I have to do in order to make aloserver react to subdomain.mydomain.com? What about DNS?

Collapse
6: Response to subsites... (response to 1)
Posted by Tilmann Singer on
Nothing special I guess - unless there is some kind of virtual hosting setup.

You only must make subsite.mydomain.com point at the current address of your server. You can test if your aolserver responds to all hostnames by typing its IP address in the browser url field and see if your site shows up.

Collapse
7: Response to subsites... (response to 1)
Posted by Don Baccus on
Sorry, David, I was wearing my OACS 4.5 hat.  Modifying the ad_header and ad_footer procs in 3.2.5 is the right thing to do, as Tilmann suggests.
Collapse
8: Response to subsites... (response to 1)
Posted by David Kuczek on
Hello Tilmann,

subsite.mysite.com is now getting redirected to mysite.com! I don't have a virtual host configuration on my box.

What would I have to do that subsite.mysite.com is being displayed in the url field of the browser instead of jumping to mysite.com?

Do I need a seperate IP for this?

Any changes to /etc/hosts?

Thanks...

Collapse
9: Response to subsites... (response to 1)
Posted by Tilmann Singer on
Make sure ForceHostP is set to 0 in nsd's config file.
Collapse
10: Response to subsites... (response to 1)
Posted by David Kuczek on
Muchos Gracias Tilmann,

works like a charm now!!!

Collapse
11: Response to subsites... (response to 1)
Posted by David Kuczek on
How can I route everybody connecting via www.mysite.com to mysite.com but still have subsite.mysite.com work...

This way cookies for mysite.com and www.mysite.com are the same!

Is there a possibility how one single cookie reacts to mysite.com, www.mysite.com AND subsite.mysite.com?

Collapse
12: Response to subsites... (response to 1)
Posted by David Kuczek on
I just tested [ns_conn host] and [ns_conn location] on my server...

[ns_conn host] doesn't show anything!! just blank

and [ns_conn location] always shows "mydomain.com" but never the subdomain which is displayed in the browser url field...

Collapse
13: Response to subsites... (response to 1)
Posted by David Kuczek on
Is there a way how I can route everybody from WWW.mysite.com do mysite.com?

So that in the end only subsites.mysite.com and mysite.com are active?

Collapse
14: Response to subsites... (response to 1)
Posted by David Kuczek on
Okay, I found a solution for this: [ns_conn host] is somehow not working. Maybe a bug in aolserver?!

I integrated the proc ad_host from oacs 4.5 (/packages/acs-tcl/tcl/request-processor-procs.tcl) into 3.2.5 and it works smoothly...

----------------------------------------------------------------

I still have one problem... Whenever ns_returnredirect is used from a subsite with an absolute location, aolserver serves "mysite.com/newlocation.tcl" instead of "subsite.mysite.com/newlocation.tcl"

An example:

I redirect /www/register.tcl directly to /www/register/user-new.tcl

a.) when I use "ns_returnredirect /register/user-new.tcl" on a subsite, aolserver redirects to

mysite.com/register/user-new.tcl

and not to

subsite.mysite.com/register/user-new.tcl...

b.) but when I use "ns_returnredirect register/user-new.tcl" aolserver redirects correctly...

How could I solve this problem???

Please don't tell me that I have to change all absolute redirects...

Collapse
15: Response to subsites... (response to 1)
Posted by David Walker on
ns_returnredirect doesn't do anything fancy so you should be passing a full url to it. Here is the proc I have replaced it with on some of my machines.
  • Won't work well with browsers that don't pass a host header but there shouldn't be many of them left.
  • Won't work right with https. Will redirect the user back to an unencrypted page
  • Won't work with an ftp redirect or other non-http redirect. Gets confused
  • Won't work with a page like http_info.htm because it starts with http.
I'll fix these issues when I feel like it but maybe this will be good enough for your site or at least a starting point.

rename ns_returnredirect _ns_returnredirect
proc ns_returnredirect {url} {
        set url_out $url

        set curr_url [ns_conn url]
        set curr_host [ns_set iget [ns_conn headers] "host"]

        if {[string range $url 0 0] == "/"} {
                set url_out "http://${curr_host}${url}"
        } elseif {[string range $url 0 3] == "http" } {
                set url_out "${url}"
        } else {
                set curr_dir [file dirname "${curr_url}xx"]
                if {[string equal ${curr_dir} "/"]} {
                        set curr_dir ""
                }
                set url_out "http://${curr_host}${curr_dir}/${url}"
        }
#ns_log notice "[info level -1] :: _ns_returnredirect $url_out"
        _ns_returnredirect $url_out
}