Forum OpenACS Q&A: ns_returnredirect includes entire hostname !?

I want to allow users to access my server as www.carnageblender.com or just carnageblender.com or even with the IP when the dns is being updated. So, I turn ForceHostP off and life is good. Except I notice that ns_returnredirect is redirecting to the cannonical hostname as defined to nssock. Thus, "ns_returnredirect /index.tcl" yields
GET /redirect.tcl HTTP/1.0

HTTP/1.0 302 Found
...
Location: http://www.carnageblender.com/index.tcl
...
Investigating, Ns_ConnReturnRedirect in nsd/return.c does this for any location beginning with "/":
        if (*url == '/') {
            Ns_DStringAppend(&ds, Ns_ConnLocation(conn));
        }
Why should this be so? My reading of the http 1.0 spec indicates that simply leaving "Location: /index.tcl" would be perfectly correct. Is there any reason I shouldn't remove this code?
Collapse
Posted by C. R. Oldham on
Are you running 4.5?  I think there is a bug in late versions of IE that causes problems with redirects.  Are you sure the problem is with ns_returnredirect and not ad_returnredirect?  I patched ad_returnredirect to get around IE brokeness.  See https://openacs.org/sdm/one-baf.tcl?baf_id=1493
Collapse
Posted by Tom Jackson on

I wrote a different version of ns_returnredirect that might be useful in your situation. You would have to adapt it. The link is http://zmbh.com/vat/vat.txt.

CR, as you can see from the telnet excerpt the problem is with nsd, not with my browser.  (I tested with nn 6 to be sure.)

Tom, I will try something like what you are doing, but I'll have to write it to get values from ns_conn rather than Template.

Collapse
Posted by Tom Jackson on

Right, that is how I get it into the Template global, check the code for that above:

set Template(host)   [string tolower [ns_set iget [ns_conn headers] host]]