301 conditional forwarding by IP to another domain

Asked

Viewed 322 times

0

I would like to redirect all users who access a particular page from one domain to the same page from another domain, except myself, I thought of using conditional IP forwarding from next way through the archive .htaccess:

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

In this case all users who browse the current site will be redirected to the same page on domainovo.com.br provided that its IP is different from 123.456.789.000 (my current ip).

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

The above code was an adaptation on its own, I don’t know if it’s the right way to do it. I got it wrong somewhere?

1 answer

1


Maybe passing the parameter of the current path to the URL is missing, do so:

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

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

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

    It worked as it should, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.