We help IT Professionals succeed at work.
Get Started

PHP Referrer not detect if redirect from another domain using .htaccess

Shamsul Kamal
Last Modified: 2020-01-12

I need an assistant.

i made 301 redirection using .htaccess to new domain name as follows :


RewriteCond %{HTTP_HOST} ^domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteCond %{REQUEST_URI} !/(fpx_indirectcallback|fpx_directcallback|molpay_callback|paypal|billplzBills)\.php [NC]
RewriteRule ^(.*)$ https://iwhost.com/$1 [L,R=301,NC]

Open in new window

and at the iwhost.com i made a php script in index.php as follows :

// Check referrer


$refData = parse_url($ref);

if($refData['host'] == 'domain.com' || $refData['host'] == 'www.domain.com'  ) {

echo "<link rel='stylesheet' href='css/swc.css'>
<div id='boxespopup'>
  <div style='top: 50%; left: 50%; display: none;' id='dialog' class='window'>
    <div id='san'>
      <a href='#' class='close agree'><img src='img/close-icon.png' width='25' style='float:right; margin-right: -25px; margin-top: -20px;'></a>
      <img src='img/notice.jpg'>
    <div style='width: 2478px; font-size: 32pt; color:white; height: 1202px; display: none; opacity: 0.4;' id='mask'></div>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js'></script>
<script src='js/swc.js'></script>";

Open in new window

The problem is that why iwhost receive empty referrer when redirect using the above method.

Please advice alternate method or idea on how to achieve my requirement.
Watch Question
This problem has been solved!
Unlock 1 Answer and 39 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE