Rewrite foo.com to bla.com/$1 ?

Per Buer perbu at varnish-software.com
Wed Jan 7 14:03:36 CET 2015


On Wed, Jan 7, 2015 at 1:55 PM, Matt . <yamakasi.014 at gmail.com> wrote:

> Hi All,
>
> In the past I tested some scripts on on varnish for rewriting a domainname.
>
> My idea would be foo.com/* to bla.com/$1
>
> Can I accomplish this with just something like:
>
> if (req.http.host ~ "foo.com") {
> set req.http.host = "bla.com/$1";
> }
>

Unless I missed something essential you could just do

if (req.http.host ~ "foo.com") {
      set req.http.host = "bar.com";
}

req.url will stay untouched. Remember that the full URL consists of
req.http.host and req.url.

-- 
*Per Buer*
CTO | Varnish Software AS
Cell: +47 95839117
We Make Websites Fly!
www.varnish-software.com
[image: Register now]
<http://info.varnish-software.com/varnish-summits-autumn-2014-registration>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150107/aa0e0e95/attachment.html>


More information about the varnish-misc mailing list