1

We're merging with another company, and we want to redirect content from their (Apache) website to our (IIS) site. When traffic arrives at our site, we inspect the HTTP_REFERER, and if the visitor was just redirected from the company's site that we just merged with, they'll be presented with a "splash" page announcing the merger.

I've added the line...

Redirect / http://www.oursite.com/

...to their .htaccess, which works fine, except that when the browser is redirected it doesn't send the HTTP_REFERER header.

I've tried redirecting with redirect codes 301, 302 and 307 (the default, I believe, is 302) and all have the same effect (redirects fine, but no HTTP_REFERER).

Can anyone provide some insight into why HTTP_REFERER wouldn't be included?

the-wabbit
  • 40,737
  • 13
  • 111
  • 174
CodeToaster
  • 115
  • 1
  • 3

1 Answers1

0

RFC doesn't specify any referrer-specific behavior in status 301 definition, nor 301-specific behavior in Referer header definition. Thus, I have to say that although this referrer-preserving behavior is logical, it is not defined in RFC and thus you can never be sure.

In short i don't belive you will be able to acomplish this with either redirect or mod_rewrite.

Your best bet would be to make a simple php code to redirect the user which will maintain the HTTP_REFERER.

Put a file named index.php on your domain root with the bellow content:

<?php
   header( 'Location: http://www.oursite.com/' ) ;
?>

Make a .htaccess and put it in your domain root directory with the bellow content:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteRule . index.php

The .htaccess file will take care that anything typed to reach your domain will hit the index.php and the index.php will take care for redirecting to the site it needs to hit.

Prix
  • 4,881
  • 3
  • 24
  • 25
  • Tried it, it does not maintain the referer http header any more than just direct redirect in .htaccess. Also tried adding referer header in PHP code - at least Chrome and Firefox do not heep the header. – JaakL May 26 '17 at 07:02