Title: .htninja Multiple Variables
Last modified: February 25, 2020

---

# .htninja Multiple Variables

 *  Resolved [yvrdarb](https://wordpress.org/support/users/yvrdarb/)
 * (@yvrdarb)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/)
 * Sorry, noobish question, but what is the proper format to use two or more variables?
 * Will the following work:
 *     ```
       <?php
       /*
        +============================================================================================+
        | NinjaFirewall optional configuration file                                                  |
        |                                                                                            |
        | See: https://blog.nintechnet.com/ninjafirewall-pro-edition-the-htninja-configuration-file/ |
        +============================================================================================+
       */
   
       // Users of Cloudflare CDN:
       if (! empty($_SERVER["HTTP_CF_CONNECTING_IP"]) &&
        filter_var($_SERVER["HTTP_CF_CONNECTING_IP"],FILTER_VALIDATE_IP)) {
          $_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_CF_CONNECTING_IP"];
       if ( $_SERVER["REMOTE_ADDR"] == '1.2.3.4' ) {
          return 'ALLOW'; // whitelist
       }
       ```
   
    -  This topic was modified 6 years, 3 months ago by [yvrdarb](https://wordpress.org/support/users/yvrdarb/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12481370)
 * Your code has a syntax error, it misses a closing `}` character.
    This one is
   fine:
 *     ```
       <?php
       /*
        +============================================================================================+
        | NinjaFirewall optional configuration file                                                  |
        |                                                                                            |
        | See: https://blog.nintechnet.com/ninjafirewall-pro-edition-the-htninja-configuration-file/ |
        +============================================================================================+
       */
   
       // Users of Cloudflare CDN:
       if (! empty($_SERVER["HTTP_CF_CONNECTING_IP"]) &&
        filter_var($_SERVER["HTTP_CF_CONNECTING_IP"],FILTER_VALIDATE_IP) ) {
          $_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_CF_CONNECTING_IP"];
       }
   
       if ( $_SERVER["REMOTE_ADDR"] == '1.2.3.4' ) {
          return 'ALLOW'; // whitelist
       }
       ```
   
 *  Thread Starter [yvrdarb](https://wordpress.org/support/users/yvrdarb/)
 * (@yvrdarb)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12483250)
 * Thanks.
 * It may make a good addition to the .htninja documentation page on the website.
 * Cheers.
 *  Thread Starter [yvrdarb](https://wordpress.org/support/users/yvrdarb/)
 * (@yvrdarb)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12485031)
 * Return ‘ALLOW’; // whitelist isn’t a unconditional all whitelist?
 * I am trying to allow MainWP through (on another server) and NF seems to like 
   block it.
 *     ```
       24/Feb/20 11:59:27  #5926404  MEDIUM       -  199.16.XXX.XXX    POST /wordpress/wp-admin/admin-ajax.php - Blocked access to admin-ajax.php - [bot detection is enabled] - XXXXXXX.com
       25/Feb/20 11:59:21  #8795847  MEDIUM       -  199.16.XXX.XXX    POST /wordpress/wp-admin/admin-ajax.php - Blocked access to admin-ajax.php - [bot detection is enabled] - XXXXXXX.com
       25/Feb/20 11:59:24  #6067405  MEDIUM       -  199.16.XXX.XXX    POST /wordpress/wp-admin/admin-ajax.php - Blocked access to admin-ajax.php - [bot detection is enabled] - XXXXXXX.com
       ```
   
 * Any suggestions?
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12488309)
 * Did you check in the firewall’s “Dashboard” page if the .htninja is detected 
   and loaded by the firewall?
 * ![](https://i0.wp.com/blog.nintechnet.com/wp-content/uploads/2018/07/htninja_wp.
   png?ssl=1)
 *  [stheoret](https://wordpress.org/support/users/stheoret/)
 * (@stheoret)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12488370)
 * Hi !
 * And when you want to allow multiple folders without filtering ??? :
 * if (strpos($_SERVER[‘SCRIPT_NAME’], ‘/my-first-folder-without-filtering/’) !=
   = FALSE) {
    return ‘ALLOW’;
 * works for the first folder, how i can add a second, third folder to this code??
 * thanks
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12489605)
 * This is regular PHP code. See some PHP tutorials if you aren’t familiar with 
   PHP.
 *     ```
       <?php
       if ( strpos($_SERVER['SCRIPT_NAME'], 'some-script.php') !== FALSE ||
          strpos($_SERVER['SCRIPT_NAME'], 'another-script.php') !== FALSE ||
          strpos($_SERVER['SCRIPT_NAME'], '/a-folder/') !== FALSE ) {
   
          return 'ALLOW';
       }
       ```
   
 * Make sure the folders exist on your site (i.e., you can see them when you connect
   over FTP). If they don’t exist, they aren’t folders but permalinks, which means
   you should use `$_SERVER['REQUEST_URI']` instead of `$_SERVER['SCRIPT_NAME']`.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘.htninja Multiple Variables’ is closed to new replies.

 * ![](https://ps.w.org/ninjafirewall/assets/icon-256x256.png?rev=976137)
 * [NinjaFirewall (WP Edition) - Advanced Security Plugin and Firewall](https://wordpress.org/plugins/ninjafirewall/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ninjafirewall/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ninjafirewall/)
 * [Active Topics](https://wordpress.org/support/plugin/ninjafirewall/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ninjafirewall/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ninjafirewall/reviews/)

## Tags

 * [htninja](https://wordpress.org/support/topic-tag/htninja/)

 * 6 replies
 * 3 participants
 * Last reply from: [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/htninja-multiple-variables/#post-12489605)
 * Status: resolved