How to individually set WP_DEBUG on a sub-directory multisite?

According to this question, it’s possible to turn on/off WP_DEBUG for specific sites on a multisite.

Is it possible to do this with a sub-directory multisite?

Related posts

2 comments

  1. You can do this by adding some code to wp-config.php

    $request_uri = $_SERVER['REQUEST_URI'];
    $debug_dirs = array ('/debug-dir1/','/debug-dir2/'); // list of directories to turn on debugging
    foreach ($debug_dirs as $debug_dir) {
        if (!strncmp($request_uri,$debug_dir,strlen($debug_dir))) {
            define('WP_DEBUG', true);
        } 
    }
    define('WP_DEBUG', false); // debug off by default
    
  2. Here is what worked for me

    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (strpos($url,'sitename') !== false) {
                define('WP_DEBUG', true);
    }
    

Comments are closed.