Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:05:38+00:00 2026-06-15T03:05:38+00:00

I am trying to get some basic routing done in ZF2 but I am

  • 0

I am trying to get some basic routing done in ZF2 but I am running into some problems.

The section that is giving me trouble is this:

'parent-categories' => array(
    'type' => 'literal',
    'options' => array(
        'route' => '/kategorier/',
        'defaults' => array(
            'controller' => 'categories',
            'action' => 'parent-categories',
        ),
    ),
    'may_terminate' => true,
    'child_routes' => array(
        'child-categories' => array(
            'type' => 'segment',
            'options' => array(
                'route' => '/kategorier[/:slug][/:parentCategoryid]/',
                'constraints' => array(
                    'parentCategoryid' => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'categories',
                    'action' => 'child-categories',
                )
            ),
        ),
    ),
),

The original ‘parent-categories’ route works just fine, no problem. The problem though is the child-categories route isn’t doing anything. I have the URL:

/kategorier/test-test-test-test-test/1/

but this is never matched to anything. I get the error:

The requested URL could not be matched by routing.

If I take the child-categories route out of the “child_routes” section, it always catches the request, even if the url is only /kategorier/. Can anyone see what I am doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:05:39+00:00Added an answer on June 15, 2026 at 3:05 am

    A child route appends to the parent route. I.e. what you’re currently matching is

    /kategorier//kategorier[/:slug][/:parentCategoryid]/
    

    Do it like this

    'parent-categories' => array(
        'type' => 'literal',
        'options' => array(
            'route' => '/kategorier',
            'defaults' => array(
                'controller' => 'categories',
                'action' => 'parent-categories',
            ),
        ),
        'may_terminate' => true,
        'child_routes' => array(
            'child-categories' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '[/:slug][/:parentCategoryid]',
                    'constraints' => array(
                        'parentCategoryid' => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'categories',
                        'action' => 'child-categories',
                    )
                ),
            ),
        ),
    ),
    

    And i guess this should be working out alright. It’s a good advice to NOT have trailing slashes, as you’d ideally always want to begin new routes with one for better readability 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to get some basic jQuery code with Rails working, but it
Trying to get some initial bearings on useful processes that a basic working knowledge
Im trying to get into some basic JavaFX game development and I'm getting confused
I am trying to get some basic unit tests up and running on the
I am trying to get my head round some basic erlang functionality and I
Just trying to get some rows out of a database and loop through but
Im trying to get some system information using WMI but the problem is when
Trying to get some basic understanding of console functionalities. I am having issues so
I have been trying to get some basic dynamic code compilation working using the
I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.