Support » Plugin: NinjaFirewall (WP Edition) - Advanced Security » Multiple Websites Using One Prepend File

  • Resolved PumpaXXL


    Hi, our host allows multiple web sites per one account but all websites can have only one prepend file which is common for all of them. So my question is if it is possible to activate Full WAF mode for all the sites using the same auto_prepend_file (from one of them).

    Thank you,

    Great plugin BTW.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author nintechnet


    You can have multiple WordPress installations with one PHP INI. But you need to do some work.
    Here’s an example:
    Scroll down to the “Multiple-site installation” section. Although this article refers to HHVM, the problem is the same: installing multiple instances of NinjaFirewall with one single PHP INI.

    Assuming you have 3 sites as per follows:

    └── /home
      └── /user
          ├── /domain_01.tld
          ├── /domain_02.tld
          └── /domain_03.tld

    1. Install NinjaFirewall on “domain_01.tld”, and load it from /home/user/.user.ini (or php.ini depending on your host).
    2. After the installation, comment out the auto_prepend_file directive to temporarily disable the firewall.
    3. Repeat steps 1 and 2 with all other sub-domains.
    4. Create a PHP script in your root folder, e.g., /home/user/my_script.php.
    5. Add this code to it and adjust the paths accordingly:

    // Prepend the firewall for domain_01.tld:
    if (strpos($_SERVER['SCRIPT_FILENAME'], '/home/user/domain_01.tld') !== false) {
       // Load the firewall:
    // Prepend the firewall for domain_02.tld:
    } elseif (strpos($_SERVER['SCRIPT_FILENAME'], '/home/user/domain_02.tld') !== false) {
       // Load the firewall:
    // Prepend the firewall for domain_03.tld:
    } elseif (strpos($_SERVER['SCRIPT_FILENAME'], '/home/user/domain_03.tld') !== false) {
       // Load the firewall:

    6. Load the above script from the PHP INI auto_prepend_file directive:

    ; BEGIN NinjaFirewall
    auto_prepend_file = /home/user/my_script.php
    ; END NinjaFirewall


    Great, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple Websites Using One Prepend File’ is closed to new replies.