2

I'm currently creating a new version of my website using Zend Framework and I'm stuck with a little problem I've seen in the past.

There are my routes: (a part)

// BLOG -> CATEGORIES $route = new Zend_Controller_Router_Route( 'blog/categories', array( 'module' => 'blog', 'controller' => 'categories', 'action' => 'index' ) ); $router->addRoute('blog-categories', $route); // BLOG -> CATEGORIES -> LIST ARTICLES (:alias = name of the category) $route = new Zend_Controller_Router_Route( 'blog/categories/:alias', array( 'module' => 'blog', 'controller' => 'categories', 'action' => 'list', 'alias' => null ) ); $router->addRoute('blog-categories-list', $route); 

The problem is that: when I go to /blog/categories/, it brings me the list action. What I don't want. I need the index.

Is there a way to fix that without using, for exemple, /blog/categories/view/:alias ?

Note: I have the same problem for /blog/ (list all articles) and /blog/:alias/ (display single article).

1 Answer 1

1

By including 'alias' => null you're specifying a default value for the :alias parameter, used if it is not in the URL. This is why your second route is always matching. Remove this and it should work as you are wanting it to.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank's for the answer! I was searching for a while now. I removed the default value and it works great now :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.