Try surrounding in parens:
$route['(.+)/schoolid(?)'] = 'somepage';
Testing here locally, this seems to work.
Here is my routes.php
:
$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['(.+)/schoolid(?)'] = 'test2/index';//echo's "test"
.htaccess
:
RewriteEngine on
RewriteBase /ci-214/
RewriteCond $1 !^(index\.php|bootstrap)
RewriteRule ^(.*)$ index.php/$1 [L]
These URL's all work (do not produce 404 and echo test from test2/index
):
http://example/ci-214/safgfgf/schoolid?/123
http://example/ci-214/safgfgf/schoolid?123
http://example/ci-214/sadf/schoolid?123
http://example/ci-214/sadf/schoolid?/
http://example/ci-214/sadf/schoolid?
http://example/ci-214/sadf/schoolid