WordPress.org

Ready to get started?Download WordPress

Forums

Using .htaccess to redirect only 1 IP (4 posts)

  1. elmsblog
    Member
    Posted 8 years ago #

    Well, I have 1 known visitor who uses the same ip address EVERY time. I have been googling for 2+ hours now, and just want to know if I can redirect this 1 ip address to a special page or alternate site altogether.

    I've been messing with Rewrite rules in my .htaccess file all day now it seems, but nothing works (testing on my own ip).

    The next question is then can I log how often it redirects this guy?

    Thanks guys!

    P h i l

  2. google_earth
    Member
    Posted 8 years ago #

    I don't know about the logging but

    order allow,deny
    allow from all
    deny from xx.xx.xx.xx

    will bar one IP address from your server

  3. Austin Matzko
    Member
    Posted 8 years ago #

    How about doing it with PHP? (I'm assuming you want to do more than just ban the user)

    if ('123.456.789.012' == $_SERVER['REMOTE_ADDR']) {
    echo 'hi Bob!';
    . . .
    }

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    RewriteCond %{REMOTE_ADDR} 1.2.3.4
    RewriteRule !^redir.php$ /redir.php [R,L]

    Where /redir.php is the file you want 1.2.3.4 to be directed to.

Topic Closed

This topic has been closed to new replies.

About this Topic