Hi!
> I dont know where to ask for help with NaviServer, so
Use this mailing list:
https://lists.sourceforge.net/lists/listinfo/naviserver-devel
> If someone can point me to any other NaviServer learning-friendly discussions, i would be glad.
It is fine to post here and point naviserver-devel to your c.l.t post, don't cross-post though.
> My question:
>
> What is the best approach to redirect www version of url to non-www?
>
It depends.
> Create virtual server for www version and then register proc which will redirect all traffic to non-www virtual server.
1) Use a "www CNAME @"?
2) Registering a www-redirecting vhost is more likely to be economical:
ns_section "ns/module/nssock/servers"
ns_param www
www.example.com
ns_section "ns/server/www"
ns_param hostname
www.example.com
ns_param library $serverdir/tcl
in $serverdir/tcl create a tcl script which register sth. along the lines:
proc nonWWW {} {
# nicer if you'd get the redirect hostname from the config file.
set url
http://example.com[ns_conn url]
set q [ns_conn query]
if {$q ne ""} {append url ? $q}
ns_returnmoved $url
}
ns_register_proc GET /* nonWWW
(run ns_register_proc for the other HTTP methods also)
There might be sth. more elegant, but for that, you need to reach out to the NaviServer ninjas. Also, mind that the above is untested and from the top of my head.
HTH,
Stefan