سؤال

I've defined following route in config file as follows.

$route['apartments/(:any)'] = 'apartments/view/$1';

If I give http://localhost/apartment_advertisement/apartments/shobha_complex like this in url it works perfectly fine.

If I give http://localhost/apartment_advertisement/apartments/shobha_complex/abcd/abcd like this in url it goes to the same page as above. So I needed error page for this url. Please help me how to control these urls?. The work would be more appreciated.

هل كانت مفيدة؟

المحلول

Do you mean display an 404-not-found error when request URL has an unwanted "tail"? You can modify (:any) to restrict accepted string. It's simple:

$route['apartments/(\w+)'] = 'apartments/view/$1';
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top