I am looking to use a URL shortening scheme where I would like the variable to be in the first segment of the URL, www.example.com/0jf08h204. My default controller is "home.php" and I have .htaccess mod-rewrites in place, so what is the best way to manage this? I suppose my smarts have been blocked by the standard /controller/method/variable scheme, is this a URI Protocol setting? Thank you!
To add to Matthew's response.
This is what you'll need in your system/application/config/routes.php
file:
$route['(:any)'] = "home";
This will redirect EVERYTHING.
You might not want to redirect everything if you have other controllers which you need to use. If that is the case you can use this regular expression instead:
$route['^(?!about|contact)\S*'] = "home";
This will allow you to redirect everything except the controllers 'about' or 'contact' -- these will be directed to the 'about.php' and 'contact.php' controllers.
Please note, I choose not to use the wild cards within CodeIgniter, you might find they work better for you, I however choose to parse out the $_SERVER['REQUEST_URI'] manually after the redirect. If however you wanted to use the wildcards you would just add /$1
to the routes as you see in Matthew's response.