• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug or "feature" ? URI Routing issue


I have set two rules :

$route['followers/(:num)'] = 'hall/filter/subscribers/$1';
And :

$route['see/(:num)'] = 'hall/see/$1';
But while the first one is working all fine, the second one behaves juste like the 2nd argument (the :num) wasn't passed at all (displaying see/4 gives the hall/see/ page, not hall/see/4 !). This is very odd because from my point of view, those 2 routes work the same way !!

Even stranger, if I change
then it works !

Any idea ? Thanks

Since CodeIgniter was written in PHP, i believe ' is different with ", for example you have declared a variable,
$foo = 'bar';
then that will be different if you do
echo '$foo';
echo "$foo";
. And in your issues with CodeIgniter routes, that would be a problem

lol, as stated on stackoverflow, this has nothing to do with my problem, for 2 reasons :
- the working example provided works with single quotes
- I changed everything to double quotes and it didn't change a thing

Well, just guessing you put your controller into sub folder, then this maybe what you need
$route['see/(:num)'] = "hall/see/index/$1";
Because its almost likely you have "hall" as sub folder in your controllers directory, and filter controller which have subscribers function. Thats the common uri routes in CI. I just can't believe quickly, then CI Route, as you quote as your thread title, fails only for you but works for other thousand developer who use it.

If you want to collaborate this issue more, post your controller here Smile

my controller is 'hall', filter is my function, broadcaster is argument #1, the number is argument #2 :/

As i stated, if you want to ellaborate this issue more, post your controller here... For sure, something was wrong with that...

Solved :

Actually I was referring to my argument in 'see' function by using $this->uri->segment(3). I thought it'd work because the routing would remap this, but actually no, it puts the real value in $this->uri->rsegments[]. So I can either use this array or put the argument between ( and ) like in a normal function

Thanks Toopay

[eluser]Reneesh T K[/eluser]
I was also the same problem and I fixed it by a small change in URI.php page in the system/core

In my checking I feel like it was due to a small bug in codeigniter. Anyway I am not an expert.

Anyway I fixed it.

I was a problem with codeigniter url rewriting.

I have to go to www.abc.com/catalog/product/4354

when using the url www.abc.com/samsung_galaxy_y

I have explained it in my blog.


@Reneesh T K, and how many times are you going to post this?

I don't want to feed any troll, but @Reneesh T K, I guess you haven't read the user's guide properly. If you look at the URI-class' class reference, you would have seen this line


which will do just what you needed.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.