CodeIgniter Forums

Full Version: Bug or "feature" ? URI Routing issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]cyrigniter[/eluser]
Hello,

I have set two rules :

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

Code:
$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
Code:
$route['see/(:num)']
to
Code:
$route['foo/see/(:num)']
then it works !


Any idea ? Thanks

El Forum

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

El Forum

[eluser]cyrigniter[/eluser]
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

El Forum

[eluser]toopay[/eluser]
Well, just guessing you put your controller into sub folder, then this maybe what you need
Code:
$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

El Forum

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

El Forum

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

El Forum

[eluser]cyrigniter[/eluser]
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

El Forum

[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.


http://myphplibrary.blogspot.in/2012/03/...n-url.html

El Forum

[eluser]InsiteFX[/eluser]
@Reneesh T K, and how many times are you going to post this?

El Forum

[eluser]PhilTem[/eluser]
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

Code:
$this->uri->rsegment(n);

which will do just what you needed.