Angelo Rodriguez
Angelo Rodriguez

Reputation: 127

Redirect IP to Another Page Using Htaccess

I would like to redirect some specific IP addresses to a different page when they access my home page using htaccess. There are 3 IP address that I want to redirect. I would like to redirect to a URL like:

www.domain.com/ --> www.domain.com/?redirect=1

How do I do this?

Upvotes: 1

Views: 2107

Answers (1)

anubhava
anubhava

Reputation: 785128

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{REMOTE_ADDR} ^(11\.22\.33\.44|21\.22\.23\.24|33\.32\.33\.34)$
RewriteRule ^/?$ /?redirect=1 [L,R=302]

Replace these IPs with your actual IP.

Upvotes: 2

Related Questions