What you need here is routes
open your application/config/routes.php
Youc could set (:any)
like this
$route['(:any)'] = 'controller/method/$1';
here you can use the wildcard any
. That if anything is entered it will direct to the controller you want it to be redirected the $1
holds the value of the segment you entered.
then on your method just do the usual query if exist or not do what you want.