Question

I have a URI route specified in my routes.php file like this:

$route['(.+)/schoolid\?'] = 'somepage';

However, when I enter random/schoolid?, it displays a 404 page instead of displaying 'somepage' as specified in the URI route. 'somepage' does exist, coz if I simply take out \?, it displays somepage upon visiting random/schoolid

I also attempted to use 2 backslashes instead of 1, like \\?, did not work either.

What am I missing ?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top