regsub, string concatenation?
varnish-list at itiva.com
Fri Apr 18 20:45:49 CEST 2008
Jon Drukman wrote:
> i'm trying to rewrite all incoming URLs to include the http host header
> as part of the destination url. example:
> incoming: http://site1.com/someurl
> rewritten: http://originserver.com/site/site1.com/someurl
> incoming: http://site2.com/otherurl
> rewritten: http://originserver.com/site/site2.com/someurl
> the originserver is parsing the original hostname out of the requested
> url. works great with one hardcoded host:
> set req.url = regsub(req.url, "^", "/site/site1.com");
> i can't get it to use the submitted http host though...
> set req.url = regsub(req.url, "^", "/site/" + req.http.host);
> varnish complains about the plus sign. is there some way to do this
> kind of string concatenation in the replacement?
set req.url = "/site/" req.http.host "/" req.url;
The extra / by itself might not be necessary. Set will allow you to
concatenate strings but I'm not sure the regsub will. I think this will
provide you what you are looking for, let me know.
More information about the varnish-misc