Abs
Abs

Reputation: 57916

Why do I get a 404, is it codeigniter routes issue?

I am having an issue with CI routes. I keep getting a 404 even though my routes are defined.

I have these routes defined in my routes config file:

$route['s'] = "s";
$route['s/(:any)'] = "s/$1";

When I try to access http://localhost/s/x4dB/stripe, I get a 404. I put a few echo and exit statements in my controller and I noticed that it reaches my controller up till the end of the constructor, after that it just throws a 404. I have the method index defined and it never reaches it.

Just to be clear, I have other routes setup and they are working correctly.

What am I doing wrong in this case?

Upvotes: 0

Views: 71

Answers (2)

Kumar V
Kumar V

Reputation: 8840

Try this :

$route['s/(:any)'] = "s/index/$1";

As we discussed in comment, While calling the controller default constructor will execute and then index function will execute if no function name mentioned.

Upvotes: 1

Aurel
Aurel

Reputation: 3740

Try this:

$route['s/(:any)'] = "s/$1";
$route['s'] = "s";

Upvotes: 0

Related Questions