我有一个包含一些静态页面的网站,我在routing_pages.yml
文件中定义了以下内容:
index:
pattern: /inicio
defaults: { template: 'FrontendBundle:Site:index.html.twig' }
contact_one:
pattern: /contact_one
defaults: { template: 'FrontendBundle:Site:contact.html.twig' }
location:
pattern: /horario
defaults: { template: 'FrontendBundle:Site:location.html.twig' }
payment:
pattern: /pagos
defaults: { template: 'FrontendBundle:Site:payment.html.twig' }
question:
pattern: /preguntas
defaults: { template: 'FrontendBundle:Site:question.html.twig' }
questionb:
pattern: /preguntasb
defaults: { template: 'FrontendBundle:Site:questionb.html.twig' }
shipping:
pattern: /politicasenvio
defaults: { template: 'FrontendBundle:Site:shipping.html.twig' }
warranties:
pattern: /garantias
defaults: { template: 'FrontendBundle:Site:warranties.html.twig' }
ml:
pattern: /ml
defaults: { template: 'FrontendBundle:Site:forms.html.twig' }
然后在主routing.yml
文件中,我将资源用作:
_paginas:
resource: routing_pages.yml
prefix: /
defaults:
_controller: FrameworkBundle:Template:template
我在尝试使用此例外访问/app_dev.php|app.php
路径时遇到了一些问题:
找不到“GET /”
的路线
这是由access_control
security.yml
access_control:
#Security Login/Register/Resetting
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
#Frontend Pages Routes
- { path: ^/inicio, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/contact_one, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/horario, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/pagos, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/preguntas, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/preguntasb, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/politicasenvio, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/garantias, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/ml, role: IS_AUTHENTICATED_ANONYMOUSLY }
#Login required
- { path: ^/, role: ROLE_USER }
- { path: ^/admin/, role: ROLE_ADMIN }
处的配置所致:
- { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
我做了什么?因为stactic页面不需要登录功能,只需管理区域。我尝试用这两行来改变这个:
/inicio
但是当我访问`app_dev.php | app.php / admin时,我没有看到登录表单,为什么?我怎么解决这个问题?有什么建议吗?
如果我可以在某个地方或以某种方式将homepage
定义为{{1}},那么问题是固定的,很难,但我不知道如何。
答案 0 :(得分:1)
您可以在路由表中定义从“/”到“/ inicio”的重定向:
# redirecting the root
root:
path: /
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /inicio
permanent: true
src:http://symfony.com/doc/current/cookbook/routing/redirect_in_config.html