Forum OpenACS Q&A: Problem redirecting domain name to subsite (with apache virtualhost)

I have openacs installed on an account that has both apache and aolserver running.

Openacs runs at http://www.myolddomain.nl:81

I'd like to point a new domain(www.mynewdomain.nl) to an openacs sub site http://www.myolddomain.nl:81/my1stsubsite). But I can't find a way to link it to the subsite, neither can I manage the new domain with the Host Node Map application.

Apache "translates" the domain name so openacs doesn't recognize the new domain name. E.g. [ad_conn location] returns "myolddomain.nl:81" instead of mynewdomain.nl

These are my apache settings:

<VirtualHost 123.456.789>
        ServerName www.mynewdomain.nl
        ServerAlias www.mynewdomain.nl
        ProxyRequests Off
        ProxyPass / http://www.myolddomain.nl:81/
        ProxyPassReverse / http://www.myolddomain.nl:81/
</VirtualHost>

I tried...
        ProxyPass http://www.myolddomain.nl:81/my1stsubsite/
        ProxyPassReverse / http://www.myolddomain.nl:81/
But it screwed up a lot of links and refernces in openacs

Could someone give me a hint in the right direction? Is there a way to pass to new domain name so openacs recognizes it?

Since it is a one-time need (once they visit the URL they should always go to that subsite), you could just create another Virtual Host entry, and inside it put a Redirect directive.

This would have the disadvantage that the use could then navigate above the subsite you want them in, into the old site's pages.  However, I don't think there is a way around this.

If you want them to keep using Apache for whatever reason, set up a Virtual Host entry and use a combination of Redirect and ProxyPass to reach the subsite, e.g.

Redirect /index.html /my1stsubsite
ProxyPass / http://www.newdomain.nl:81/my1stsubsite/
ProxyPassReverse / http://www.newdomain.nl:81/my1stsubsite/

You will probably need to test to be sure everything works as you expect, especially on login, where OpenACS issues redirects itself.

That wouldn't work, actually ... when I add in the Redirect as written above, it causes Apache to crash, as a Redirect is supposed to be to another URL :(

Putting the two ProxyPass entries in does help things though, but he has references hardcoded in his HTML to /my1stsubsite, which, of course, the ProxyPass entries "hide", so he ends up tryign to "Proxy"

http://www.myolddomain.nl:81/my1stsubsite/my1stsubsite, which, of course, fails ...

Collapse
Posted by Willy Jansen on
here is the problem i´m breking my neck on (for weeks now):

i have openacs running (without problems) at http://www.myolddomain.nl and i created the subsite http://www.myolddomain.nl/subsite1

i got myself a second domainname (www.mynewdomain.nl) and want to point that the subdirectory, but without omitting /subsite1. when the subdirectory is omitted all links start to break and edit-this-page ceases to work.

i tried it with the host-node-map but (a) it breaks links and (b) aolserver crashes mysteriously.

a simple redirection based on the url would be enough...
i tried to redirect it using [ad_conn location], but [ad_conn location] returns "www.myolddomain.nl" instead of "www.mynewdomain.nl"

- what might be the problem here?
- are there alternative ways (to host-node-map) to redirect domain names?
- how can i let openacs return the URL that the visitors enters in his browser?

Any help would be highly appreciated.

I've got the setup working with Apache/virtual hosts mapped using the nost node map. It works more or less flawlessly, although I struggled with it initially.

Here are my virtual host files:

(Old domain)

<VirtualHost 123.456.789>
        ServerName www.myolddomain.nl
        ServerAlias myolddomain.nl

        Documentroot "/usr/local/www/myolddomain.nl/www"
        DirectoryIndex index.php index.php3 index.html index.cgi index.htm home.htm

        ErrorLog /var/www/myolddomain.nl/www/error_log
        CustomLog /var/www/myolddomain.nl/www/access_log combined

        Alias /stats  /usr/local/stats/myolddomain.nl/www

        ProxyRequests           Off
        ProxyPass               /       http://myolddomain.nl:82/
        ProxyPassReverse        /       http://myolddomain.nl:82/
</VirtualHost>

(New domain)

<VirtualHost 123.456.789>
        ServerName www.mynewdomain.nl
        ServerAlias mynewdomain.nl

        Documentroot "/usr/local/www/myolddomain.nl/www/mynewdomain"
        DirectoryIndex index.php index.php3 index.html index.cgi index.htm home.htm

        ErrorLog /var/www/mynewdomain.nl/www/error_log
        CustomLog /var/www/mynewdomain.nl/www/access_log combined

        Alias /stats  /usr/local/stats/mynewdomain.nl/www

        ProxyRequests           Off
        ProxyPass               /       http://mynewdomain.nl:82/
        ProxyPassReverse        /       http://mynewdomain.nl:82/
</VirtualHost>

You may not need all the lines in the virtual host files, but these ones work for me.

One thing you may need to do is to manually create the subdirectory you are using as your subsite location. I had some of the same problems you are referring to until I went in and manually created the "mynewdomain" directory under the "www" directory of the main site (note the "Documentroot" parameter for the new domain).

I don't think you want your ProxyPass parameter on the new domain to be pointing to the old domain. You want to let the request processor on the main site process the request through the host node map.

Collapse
Posted by Willy Jansen on
The thing is: I couldn't figure out how to do this with Apache so now I use aolserver to handle the domain names...

I'm not 100% sure about this though, because I don't know how to check that. But when I turn off apache, everything keeps working fine.

However I would be saved if I could get openacs to return the URL from the address bar. But if I type in "www.mynewdomain.nl" in the address bar the function [ad_conn location] returens "www.myolddomain.nl"

Try: Don't use the host-node-map to redirect to a subsite.
i found something really helpfull

[util_current_location]!!!!!!! thanks lars & peter

so i solved it amateuristic but exactly like I wanted.
i added at the top of acs-subiste/www/index.tcl (the page that is called by default in openacs5):

set url_in_address_bar [util_current_location]
switch $url_in_address_bar {
    "http://myolddomain.nl" { # just move on
    }
    "http://mynewdomain.nl" {
        ad_returnredirect http://www.mynewdomain.nl/vtv/vn
    }
    "http://www.mynewdomain.nl" {
        ad_returnredirect http://www.mynewdomain.nl/vtv/vn
    }
    default { # just move on
    }
}

thank you for the suggestions