Basically you only want to show a valid page if their is the correct number URI segments in the URL that represents a parameter in the query.
You should check the number of
URI segments as a pre-process before calling any other methods. This way you can be sure that there is in fact only 1 segment in the URL
If you find that there exists more than 3 segments in your
URL, then handle that situation accordingly with the convenient functions that CodeIgniter offers such Error Handling.
You can check for the correct number of segments in the URL, and if it not what you want it to be, then call the
In the example URL you posted:
http://myweburl/Everything/gov/2/order.txt , there is actually 4 segments.
// from the docs http://codeigniter.com/user_guide/libraries/uri.html
$total_segments = $this->uri->total_segments();
// 3 segments would be the max if this is your url:
// http://myweburl/Everything/gov/2/order.txt (this url contains 4 segments)
// this means that there are 3 segments in your URL
// you don't want to have more than 3, so check for that
// with the total_segments() function
if($total_segments > 3)
$valid = false;
$valid = true;
// process data as usual