Arc Forumnew | comments | leaders | submitlogin
1 point by aw 5036 days ago | link | parent

With the svr-misc1 patch the "Host" header will be available in the request. For example, if I'm browsing to www.example.com:8080/foo/bar, then

  (alref req!headers "Host")
will be "www.example.com:8080".

I can then extend respond to take action for a particular host

  (extend respond (req) (begins (alref req!headers "Host") "www.")
    ...)
such as by issuing a redirect, something like:

  (extend respond (req) (begins (alref req!headers "Host") "www.")
    (prn "HTTP/1.0 302 Moved")
    (prn "Location: example.com/foo/bar")
    (prn))
sorry I haven't tested this; you'll want to look at what you actually get with a tool like curl to make sure that it's right.


1 point by aw 5033 days ago | link

correction: the "Location" header should include the full URL including the http: or https:. Also you may want a 301 "moved permanently"...:

  HTTP/1.0 301 Moved Permanently
  Location: http://www.example.org/foo/bar

-----

1 point by markkat 5035 days ago | link

Thanks aw. I'll do my best to take it from there. It's appreciated. I've so little experience with this.

-----

2 points by aw 5035 days ago | link

Do post again as soon as you run into any problems or get stuck anywhere. (It will not only help you, but also the people who come after you who need the same thing you do).

-----

1 point by markkat 5035 days ago | link

Will do. It might take a a few days to get to this, but I'll post my problems, and hopefully, progress. :)

-----