Routing problems

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:

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

and my controller:

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?

Have you got any wildcard routes before this one that might be causing it to go somewhere else?

[eluser]Andreas Bergström[/eluser]

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

I don't have any wildcards before it and here is my htaccess file:

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

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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