Title: Ips
Last modified: August 18, 2016

---

# Ips

 *  [michalas](https://wordpress.org/support/users/michalas/)
 * (@michalas)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/ips/)
 * Well here’s the code I want to use to ban ips using php:
 * <?php
    $banned_ip = array(); $banned_ip[] = ‘123.123.123.123’; //specific $banned_ip[]
   = ‘222.222.222; //beginning with those 3 sets $banned_ip[] = ‘222.222’; //222.222.1.1,
   222.222.242.142, etc. $banned_ip[] = ’25’; //let’s block anything beginning with
   25
 * foreach($banned_ip as $banned) {
    $ip = $_SERVER[‘REMOTE_ADDR’]; if(0 === strpos(
   $ip, $banned)) { header(“Location: “.”[URL TO SEND PEOPLE TO]”); exit(); } } ?
   >
 * I want to ban a user from all pages so I should put it in my header.php, right?
   Which part do I put it in? The <body> section? the <head>? or before the <html
   >? Where? Thank you. x

Viewing 1 replies (of 1 total)

 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/ips/#post-342408)
 * <head> should do it.
    Or even index.php at root ?
 * Or you could use .htaccess ?

Viewing 1 replies (of 1 total)

The topic ‘Ips’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Mark (podz)](https://wordpress.org/support/users/podz/)
 * Last activity: [20 years, 3 months ago](https://wordpress.org/support/topic/ips/#post-342408)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
