user1275378
user1275378

Reputation:

CodeIgniter routes are not working

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.

Upvotes: 4

Views: 170

Answers (1)

user1902830
user1902830

Reputation:

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';

Upvotes: 3

Related Questions