我的路由有一个大问题:所有页面都匹配相同的路由!
路由.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>
当我单击菜单上的按钮(_header)时,我总是被重定向到联系人页面,并且观看日志,我可以看到
Match route "contatti" (/:sf_culture/:contatti.html) for /es/obras.html with parameters array ( 'module' => 'contatti', 'action' => 'index', 'sf_culture' => 'es', 'contatti' => 'obras',)
这怎么可能?我使用了@route sintax,所以我告诉 symfony 使用特定的路由,但这被忽略了。
您对如何解决有任何想法吗?
非常感谢