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 7699613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:31:12+00:00 2026-05-31T22:31:12+00:00

Two month ago I asked, how to realize the routing with language parameter in

  • 0

Two month ago I asked, how to realize the routing with language parameter in uri here: Locale in Routing, Default Language also without Parameter

But now, to avoid double content, I want to have the default language (en) without and other languages with parameter. In other words i need to define the route-prefix according to the _locale parameter.

Example

http://example.com/
http://example.com/de/
http://example.com/about/
http://example.com/de/about/
...

Here is my testing setup, which gives me the error show below:

routing.yml:

_site_en:
    resource: "@MyMainBundle/Controller/SiteController.php"
    type:     annotation
    requirements: { _locale : en }
    prefix: /

_site:
    resource: "@MyMainBundle/Controller/SiteController.php"
    type:     annotation
    requirements: { _locale : fr|es|it|de }
    prefix: /{_locale}/

Controller Annotations

 /**
  * @Route( "/", name="_site_startpage", defaults={"_locale" = "", "slug"="startpage"} )
  * @Route("/{slug}/", name="_site_site", defaults={"_locale"=""})
  *
  * @ParamConverter("page", class="MyMainBundle:Page")
  */
public function siteAction( $slug, $_locale, Page $page )

How to do it the right way?

Edit:
As a Result I get an Exception, that the Route to the path is not defined.

No route found for "GET /"
404 Not Found - NotFoundHttpException
1 linked Exception:
ResourceNotFoundException »

router:debug only shows the 2nd route:

_site_startpage                   ANY      /{_locale}/
_site_site                        ANY      /{_locale}/{slug}/

Edit 2:
I ended up using the JMSI18nRoutingBundle…

  • 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-05-31T22:31:13+00:00Added an answer on May 31, 2026 at 10:31 pm

    In your routing.yml for the first, the type “annotation” specifies that your controller must be introspected for routes. Everything else is ignored I think. You should try removing the type or changing it to yml, removing the resource entry and specifying the value of the _controller parameter… I think you should look at what the format for yml route definition actually is.

    Or define this default route with an annotation too.

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

Sidebar

Related Questions

Ben Copsey has abandoned ASIHTTPRequest. It has been announced almost two months ago but
a month ago I asked this question: Trying to find the top 3 properties
Edited to add more details: (originally asked nearly two months ago...still haven't found a
I asked this question two months ago and got nary an answer. In fact
Several months (maybe even a year or two) ago, I saw an asp .net
I've created two functions to load expanded views of a month in the archive
I want to match a date in the format day/month/year. where day is two
Two years ago, we shipped a multi-gigabyte Windows application, with lots of video files.
A couple of month ago I wrote a simple program in Java. I have
Our team started using mercurial about a month ago and it was a rough

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.