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?

1 Answer 1


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:

   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.

  • 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, 2017 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.