This is what I'm looking for:
If the referrer includes https://l.facebook.com/
, redirect all the pages to sub.example.com/...
If the referrer includes https://t.co/
, redirect all the pages to sub2.example.com/...
How do I do that in my nginx conf?
This approach should work:
First we define a map that assigns values to
$redirect_referer
based on HTTP Referer field contents.Then in
server
block we check if we should redirect, then we do the 301 redirect to the destination. You might want to use 302 temporary redirect instead in this case, but you need to think about all the details.