Forum Moderators: phranque
RewriteCond %{HTTP_REFERER} ^.*example.com [NC]
RewriteRule ^ - [CO=REFERER_REDIRECT:"%{HTTP_REFERER}":.example.com:1440:/]
1.2.3.4 - - [13/Jan/2015:15:52:07 --0500] [www.example.com/sid#a7aa78][rid#e59610/initial] (5) setting cookie 'REFERER_REDIRECT=.example.com; path=/; domain=1440; expires=Tue, 13-Jan-2015 20:52:07 GMT'
1.2.3.4 - - [13/Jan/2015:15:52:07 --0500] [www.example.com/sid#a7aa78][rid#e59610/initial] (5) skipping already set cookie 'REFERER_REDIRECT'
1.2.3.4 - - [13/Jan/2015:15:52:07 --0500] [www.example.com/sid#a7aa78][rid#e59610/initial] (5) skipping already set cookie 'REFERER_REDIRECT'
SetEnvIf Referer "^.*(dev.example.net)" TEST_REFERER=$1
RewriteCond %{HTTP_REFERER} ^.*dev.example.net [NC]
RewriteRule ^ - [CO=REFERER_REDIRECT:%{ENV:TEST_REFERER}:.example.com:1440:/]
[edited by: dfresh4130 at 9:51 pm (utc) on Jan 13, 2015]
RewriteCond %{HTTP_REFERER} example\.com/(.+)
RewriteRule (^|/|html)$ - [CO=newtest:%1:.example.com:525600] RewriteCond %{HTTP_REFERER} example\.com/$
RewriteRule (^|/|html)$ - [CO=newtest:root:.example.com:525600] The below rule works
RewriteCond dev\.internal\.test\.net/(.+)
RewriteRule ^ - [CO=TEST_REDIRECT:%1:.example.com:1440:/]
1.2.3.4 - - [13/Jan/2015:17:31:45 -0500] "GET /us/en/landing.html HTTP/1.1" 200 151637 "http://dev.internal.test.net:9100/test-redirect/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0" 109376
RewriteCond dev\.internal\.test\.net/(.+)
RewriteCond dev\.internal\.test\.net/(.+)
<snip>
1.2.3.4 - - [13/Jan/2015:17:31:45 -0500] "GET /us/en/landing.html HTTP/1.1" 200 151637 "http://dev.internal.test.net:9100/test-redirect/"
From reading I know colons are used as delimiters for mod_rewrite cookie options, so that can break it. Not sure if there's any way I can properly test on this setup to include the full URL of the referrer since it contains port number.
http://www\.(example\.com)(?::8888)?/(.+)
RewriteCond %{HTTP_REFERER} test\.com [NC]
RewriteRule ^(.*) - [CO=REDIRECTED:%{HTTP_REFERER}:.example.com:1440:/]
1.2.3.4 - - [27/Jan/2015:19:06:54 -0500] "GET /store/brands/product1.html HTTP/1.1" 404 12638 "http://www.test.com/redirectLinks.html" "Mozil
la/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0"
1.2.3.4 - - [27/Jan/2015:18:32:40 --0500] [www.example.com/sid#1b92ba8][rid#1daab80/initial] (4) RewriteCond: input='http://www.test.com/redirectLinks.html' pattern='
^(.*)test\\.com/(.+)' [NC] => matched
1.2.3.4 - - [27/Jan/2015:18:32:40 --0500] [www.example.com/sid#1b92ba8][rid#1daab80/initial] (5) setting cookie 'REDIRECTED=http; path=1440; domain=//www.test.com/redirectLinks.html; expires=Tue, 27-Jan-2015 23:32:40 GMT'
SetEnvIf Referer "(.*test.com.*)" REFERER=$1
Header add Set-Cookie "REDIRECTED=%{REFERER}e; domain=.example.com; path=/"
I'm at a loss as to how to get mod_rewrite to strip off the http:// part of the referrer.
RewriteCond %{HTTP_REFERER} (example\.com/blahblah)
RewriteRule ^(.*) - [CO=REDIRECTED:%1:.example.com:1440:/] SetEnvIf Referer http://www\.(test.com.+) REFERER=$1