Search returns “Nothing Found” on a sub directory

Ok, well this is not exactly to do with subdirectories as such, but there is something mixing up the queries between the subsites…

As you can see the error is saying wp_posts.post_title is not found – because the table selected is actually FROM wp_2_posts… showing the different table prefixes for site 1 wp_ and site 2 wp_2_… so one will not be found within the other.

It could be the form action destination perhaps, try replacing home_url("https://wordpress.stackexchange.com/") with get_site_url(null, "https://wordpress.stackexchange.com/"), and hopefully the search form will post to the correct site. Not sure if that will fix it though.

Otherwise it could be a plugin that doesn’t support multisite messing up the search query somehow by not using $wpdb->prefix instead of wp_ when creating the query. If that’s the case try disabling any plugins that might be doing that…