Conditional 301 redirect for IP to another domain

0

I would like to redirect all users who access a particular page from one domain to the same page in another domain except myself, I thought about using the conditional redirect by following way through the .htaccess file:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=123.456.789.000
RewriteRule .* http://dominionovo.com.br/ [R=301,L]

In this case all users who browse the current site will be redirected to the same page at dominionovo.com as long as the IP of the same is different from 123,456,789,000 > (my current ip).

Apparently it worked as expected, except when the page of the current domain is called through an iframe in the new domain.

The code above was an adaptation on its own, I do not know if it's the right way to do this. Did I go somewhere?

    
asked by anonymous 17.08.2017 / 04:00

1 answer

1

Maybe you're missing the pass the current path parameter to the URL, so:

RewriteRule (.*) http://dominionovo.com.br/$1 [R=301,L]

If you want to redirect querystrings you may need to add the QSA flag, like this:

RewriteRule (.*) http://dominionovo.com.br/$1 [R=301,QSA,L]
    
17.08.2017 / 09:52