Rewrite name.domain.tld to domain.tld/foo/bar-name

Matt . yamakasi.014 at gmail.com
Sun Jan 31 04:20:16 CET 2016


I'm actually kinda stuck here with the following:

I redirect as I said:

name.domain.tld -> domain.tld/foo/bar-name

this works OK, but as I can access domain.tld/foo/bar/name also
normally it works with local javascript:

/js/libs/etc...

but when I access that page using my rewrite it cannot find the root
ofcourse for that javascript folder and I cannot place it on a static
server, that is a big issue.

so: username.domain.tld/js is not found and my script falls back to /js....


can I do something on apache about this or do I need to handle it on
varnish as that actually does the rewrite

2016-01-31 4:00 GMT+01:00 Matt . <yamakasi.014 at gmail.com>:
> varnish 4.0
>
> The issue is that when I set a /$1 behind my destination it redirects
> to the destination and doesn't rewrite.
>
> 2016-01-31 3:19 GMT+01:00 Carlos M. Fernández <cfernand at sju.edu>:
>> Which version of Varnish?
>>
>> It seems that you want to change the URL presented to the backend. In that case, you should look into the URI and host name in the backend request instead of the client request, likely in vcl_backend_fetch (version 4.0+).
>>
>> Best regards,
>> --
>> Carlos M. Fernández
>> Enterprise Systems Manager
>> Saint Joseph's University
>> W: 610-660-1501
>> M: 215-316-1193
>> E: cfernand at sju.edu
>>
>>> On Jan 30, 2016, at 17:39, Matt . <yamakasi.014 at gmail.com> wrote:
>>>
>>> HI,
>>>
>>> I'm trying to rewrite a domainname what is typed in the addressbar but
>>> keep it overthere that way.
>>>
>>> At the moment my vcl ends up with:
>>>
>>>    set req.http.Host = regsub(req.http.X-Redirect-To, {"^([^/]+)/.*"}, "\1");
>>>                set req.url = regsub(req.http.X-Redirect-To,
>>> {"[^/]+(/.*)"}, "\1");
>>>                std.syslog(29, "Redirecting to host "+req.http.Host+";
>>> URI="+req.url);
>>>                return (pass);
>>>
>>> But this really seems to redirect.
>>>
>>> What are my options here ?
>>>
>>> Thanks,
>>>
>>> Matt
>>>
>>> _______________________________________________
>>> varnish-misc mailing list
>>> varnish-misc at varnish-cache.org
>>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc at varnish-cache.org
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list