Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Routing bad URLs

$
0
0
Hi to all developers...

My question is about routing and redirect bad URLs.

Suppose I've a controller, User, with some methods, method_1, method_2, method_3. When I passed parameters to methods:

My_URL/user/method_1/integer
My_URL/user/method_2/chars
etc.

In each method, first I validate passed parameter and then do operations. 

My question is: when users type something like these:

My_URL/user/method_1/integer/integer/chars
My_URL/user/method_2/chars/integer/integer

or some bad URLs like these, is it a good approach to handle these problems with routing?

in fact, I write these routing (I know the first ones has more precedence):

PHP Code:
$route['user/method_1/(:num)'] = 'user/method_1/$1';
$route['user/method_1/(:any)'] = 'user/index'

I test it in localhost and every thing is good. When I enter bad URLs, like:

My_URL/user/method_1/integer/integer/chars

I redirect to user's index method.
Is it a good handling?
What is cos and pros?
Is it better I check in each method total segments and do handling there (URI library, [b]total_segments() methods)?[/b]

thanks...

Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>