In my project to set up a lot of 301 redirects for sunsetting one domain and redirecting all the specific URIs to another I have the requirement to create a cookie that contains the referrer for tracking purposes. Of course with a 301 you lose that. Are there any options or workarounds that someone can point me to to accomplish this? My googling hasn't turned up anything solid so far, but I'm sure this is something that comes up fairly often. Note that the 301s are on servers in the old.com domain and the cookie rule is on the servers in new.com. Below is a basic flow example:
old.com --> 301 to new.com and corresponding URI --> new.com sets cookie using the below rewrite --> code on new.com fires off correct logic if cookie is present
#Rewrite rule on new.com servers
SetEnvIfReferer old.com OLD_REFERER=$1
RewriteCond %{HTTP_REFERER} old.com [NC]
RewriteRule ^ - [CO=OLD_REDIRECTED:%{ENV:OLD_REFERER}:.new.com:1440:/]