Multisite Subdirectories $blog_id, get_current_blog_id(), $wpdb->prefix always returns info for site 1

I’ve used trellis with bedrock to create a wordpress multisite (subdirectories) for local development.

I specified a different table prefix before provisioning, so it’s not wp_, it’s example_.

I created a second site, so there are two. Site 1 is the primary at example.test. Site 2 is at example.test/template/. Their tables have the prefixes, example_ and example_2_ respectively.

I have a plugin that does some database queries using $wpdb->prefix to get the correct info for each site, but my php script is always returning example_, even when the script is called from site 2. I error_log($blog_id) and error_log(get_current_blog_id()) to see what they would return and they are always 1, even when on site 2.

Also, I added a test.php file to the site root, next to index.php and wp-config.php. I can access it at example.test/test.php but when I try to access it from example.test/template/test.php I get an error, “Sorry, but the page you were trying to view does not exist.”

Has anyone had the same trouble and solved it?

Thank you,