Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NaviServer redirects

43 views
Skip to first unread message

P8j6

unread,
Apr 3, 2017, 11:43:17 AM4/3/17
to
Hi!

I dont know where to ask for help with NaviServer, so, since NaviServer is about Tcling, i putting it here :)
If someone can point me to any other NaviServer learning-friendly discussions, i would be glad.

My question:

What is the best approach to redirect www version of url to non-www?

Create virtual server for www version and then register proc which will redirect all traffic to non-www virtual server.

Or point both domains to one virtual and use filter of some kind?

Or someting else?

Thx for help!

stefan

unread,
Apr 3, 2017, 4:13:14 PM4/3/17
to
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
0 new messages