Perfect! I figured there was a way to accomplish this, but I hadn't thought
about manipulating the headers.
Thanks!

--Scott

On Thu, Nov 20, 2014 at 11:17 AM, Baptiste <[email protected]> wrote:

> On Thu, Nov 20, 2014 at 4:39 PM, Scott Severtson
> <[email protected]> wrote:
> > I've read the manual and searched extensively on this, but I seem to be
> > missing something. How can I substitute just the requested *hostname*
> > (excluding a non-standard port) in a redirect? I tried:
> >
> > http-request redirect prefix http://%[hdr(host)].example.com code 301
> >
> >
> > However, this preserves the non-standard port number if specified in the
> > request, resulting in something like:
> >
> > Request:
> > GET / HTTP/1.1
> > Host: original-hostname.com:81
> >
> > Response:
> > HTTP/1.1 301 Moved Permanently
> > Location: http://original-hostname.com:81.example.com/
> >
> > I'll have a fairly sizeable and dynamic lists of hosts, so adding
> explicit
> > per-host ACLs/redirects is not desired.
> >
> > Is there any way to strip the requested port from the host header? Is
> there
> > any other way to substitute just the requested hostname?
> >
> > Thanks!
> > --Scott
>
>
> Hi Scott,
>
> You can try to strip it before generating the rewrite:
> http-request replace-value Host (.*):.* \1 if { hdr_sub(Host) : }
> http-request redirect prefix http://%[hdr(host)].example.com code 301
>
> Baptiste
>

Reply via email to