# Application is going to the wrong route

**URL:** https://discourse.slimframework.com/t/application-is-going-to-the-wrong-route/56
**Category:** Questions
**Created:** [March 30, 2016, 4:46am UTC](https://discourse.slimframework.com/t/application-is-going-to-the-wrong-route/56 "2016-03-30T04:46:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![daveymcnight](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@daveymcnight](https://discourse.slimframework.com/u/daveymcnight)
#### Post date: [March 30, 2016, 4:46am UTC](https://discourse.slimframework.com/t/application-is-going-to-the-wrong-route/56/1 "2016-03-30T04:46:09Z")

</div>

Okay so I have a factory that instantiates my model and service classes. I am also rendering views. My application is a simple crud application. I am getting a url error.

This is my href.

href="/detail/Beer/{{[beer.id](http://beer.id)}}

THIS is my route for my view

$app-\>get(  
’/detail/:class/:id’,  
function ($class, $id) use ($app, $log){  
if(!$log-\>isUserLoggedIn()){  
$app-\>redirect(’/login’);  
}else {

```
        if($class == "Beer"){
            $app->render('beer/beer.php', array('beer_id' => $id));
        }
        if($class == "Brewery"){
            $app->render('brewery/brewery.php', array('brewery_id' => $id));
        }
        if($class == "Type"){
            $app->render('add-type-view.php');
        }
    }
}

```

);

**I am getting this error:**  
**Fatal error** : Uncaught Error: Class ‘detail’ not found in /Users/McDavis/Documents/repos/tap-room-web-tool/domain/Factory/Factory.php:36  
Stack trace:  
0 /Users/McDavis/Documents/repos/tap-room-web-tool/index.php(244): Factory-\>getModel(‘detail’)  
1 [internal function]: {closure}(‘detail’, ‘app.js’)  
2 /Users/McDavis/Documents/repos/tap-room-web-tool/Slim/Route.php(468): call\_user\_func\_array(Object(Closure), Array)  
3 /Users/McDavis/Documents/repos/tap-room-web-tool/Slim/Slim.php(1357): Slim\Route-\>dispatch()  
4 /Users/McDavis/Documents/repos/tap-room-web-tool/Slim/Middleware/Flash.php(85): Slim\Slim-\>call()  
5 /Users/McDavis/Documents/repos/tap-room-web-tool/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash-\>call()  
6 /Users/McDavis/Documents/repos/tap-room-web-tool/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride-\>call()  
7 /Users/McDavis/Documents/repos/tap-room-web-tool/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions-\>call()  
8 /Users/McDavis/Documents/repos/tap-room-web-tool/in in **/Users/McDavis/Documents/repos/tap-room-web-tool/domain/Factory/Factory.php** on line **36**

This is the route it is entering on line 244:

$app-\>get(’/:class/:id’, function ($class, $id) use ($factory){  
$obj = $factory-\>getModel($class);  
$svc = $factory-\>getService($obj);  
echo json\_encode($svc-\>get($id));  
}  
);

So I do not know why it is entering this route.

I am using SLIM 2.7 I believe.

---

<div class="post-metadata">

### Author: ![daveymcnight](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@daveymcnight](https://discourse.slimframework.com/u/daveymcnight)
#### Post date: [March 30, 2016, 4:06pm UTC](https://discourse.slimframework.com/t/application-is-going-to-the-wrong-route/56/2 "2016-03-30T16:06:35Z")

</div>

The version is 2.6.2 actually

---

<div class="post-metadata">

### Author: ![herman](https://avatars.discourse-cdn.com/v4/letter/h/eada6e/32.png) [@herman](https://discourse.slimframework.com/u/herman)
#### Post date: [March 30, 2016, 11:21pm UTC](https://discourse.slimframework.com/t/application-is-going-to-the-wrong-route/56/3 "2016-03-30T23:21:59Z")

</div>

how about the .htaccess file ? the .htaccess file need to place in same location with index.php

---

<div class="post-metadata">

### Author: ![daveymcnight](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@daveymcnight](https://discourse.slimframework.com/u/daveymcnight)
#### Post date: [March 31, 2016, 3:45pm UTC](https://discourse.slimframework.com/t/application-is-going-to-the-wrong-route/56/4 "2016-03-31T15:45:24Z")

</div>

This is my .htaccess. It is in the same directory as the index.php file

RewriteEngine On

Some hosts may require you to use the `RewriteBase` directive.  
If you need to use the `RewriteBase` directive, it should be the  
absolute physical path to the directory that contains this htaccess file.

RewriteBase /

RewriteCond %{REQUEST\_FILENAME} !-d  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^ index.php [QSA,L]
