Symfony1 symfony:路由总是在同一条路径上进行

Symfony1 symfony:路由总是在同一条路径上进行,symfony1,symfony-1.4,url-routing,Symfony1,Symfony 1.4,Url Routing,我在路由方面遇到了一个大问题:所有页面都匹配相同的路由 路由.yml # default rules homepage: url: / param: { module: home, action: index } # generic rules # please, remove them by adding more specific rules localized_homepage: url: /:sf_culture/ param: { module: home,

我在路由方面遇到了一个大问题:所有页面都匹配相同的路由

路由.yml

# default rules
homepage:
  url:   /
  param: { module: home, action: index }

# generic rules
# please, remove them by adding more specific rules

localized_homepage:
  url:   /:sf_culture/
  param: { module: home, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)

change_language:
  url:   /change_language
  param: { module: language, action: changeLanguage }

contatti:
  url:   /:sf_culture/:contatti.html
  param: { module: contatti, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)

about:
  url:   /:sf_culture/:about.html
  param: { module: about, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)

opera_slug:
  url:   /:sf_culture/opere/:operaslug.html
  class:    sfDoctrineRoute
  param: { module: opera, action: permalink }
  options:  { model: Opera, type: object }
  requirements:
    sf_culture: (?:it|en|es|fr)

opere:
  url:   /:sf_culture/:opere.html
  param: { module: opera, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)


default_index:
  url:   /:module
  param: { action: index }

default:
  url:   /:module/:action/*
_header.php

<ul>
<li><?php echo link_to(__('Home'), '@homepage') ?></li>
<li><?php echo link_to(__('About'), '@about?about='.strtolower(__('About'))) ?></li>
<li><?php echo link_to(__('Works'), '@opere?opere='.strtolower(__('Works'))) ?></li>
<li><?php echo link_to(__('Contacts'), '@contatti?contatti='.strtolower(__('Contacts'))) ?></li>
</ul>
怎么可能呢?我使用了@route sintax,所以我告诉symfony使用特定的路由,但这被忽略了

你知道怎么解决吗


非常感谢

Symfony从上到下匹配路由,因此Symfony找到匹配的第一条路由将被执行

您的路线在模板中正确展开,但当发出请求时,symfony将
/es/obras.html
@contatti
路线正确匹配。这是因为“obras”与“:contatti”参数匹配

要解决您的问题,您需要为symfony提供一种唯一匹配URL的方法

希望这对你现在更有意义

编辑(唯一路线):

contatti:
  url:   /:sf_culture/contact/:contatti.html
  param: { module: contatti, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)

about:
  url:   /:sf_culture/about/:about.html
  param: { module: about, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)

是的,我知道symfony从上到下匹配路由,但我认为明确告诉路由的名称,然后系统将使用该名称。。。你有什么建议可以让这些路线与众不同吗?谢谢,太好了,谢谢。现在通过你的编辑,我理解了你的暗示。。。所以这不可能有像www.webisite.com/about.html和www.website.com/contatti.html这样的URL?
contatti:
  url:   /:sf_culture/contact/:contatti.html
  param: { module: contatti, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)

about:
  url:   /:sf_culture/about/:about.html
  param: { module: about, action: index }
  requirements:
    sf_culture: (?:it|en|es|fr)