Routing problems

#1
[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?

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

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

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

#4
[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]

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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