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
}