CodeIgniter Forums
Routing problems - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Routing problems (/showthread.php?tid=21607)



Routing problems - El Forum - 08-15-2009

[eluser]Unknown[/eluser]
I am trying to route a URL such as: inventory/30/seo-string to inventory/view/30/seo-string. I don't know what I am doing wrong but I can't seem to get this to work. Here is my route code:

Code:
$route['inventory/([0-9]+)/(:any)'] = "inventory/view/$1/$2";

and my controller:

Code:
<?php
class Inventory extends Controller
{
    function index() { }

    function view()
    {
        echo $this->uri->segment(3);
    }
}

I am getting a 404 Page Not Found when I try to visit the url posted above. What am I doing wrong?


Routing problems - El Forum - 08-15-2009

[eluser]Dam1an[/eluser]
Have you got any wildcard routes before this one that might be causing it to go somewhere else?


Routing problems - El Forum - 08-15-2009

[eluser]Andreas Bergström[/eluser]
$route['inventory/:num/:any']

Should work? Provided you have mod_rewrite and .htaccess in order?


Routing problems - El Forum - 08-15-2009

[eluser]Unknown[/eluser]
I don't have any wildcards before it and here is my htaccess file:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|scripts|sitemap\.xml)
RewriteRule ^(.*)$ /index.php/$1 [L]



Routing problems - El Forum - 08-15-2009

[eluser]wabu[/eluser]
Everything you posted looks okay to me (I plugged your route, sample function and .htaccess into an app and it works for me).

Is the rest of your app working? If so, I suggest experimenting with a simpler version of the route and building it back up once that works.