我是Symfony3的新手。
如何将基本网址https://example.com
更改为https://example.com/is/
?
整个应用程序应从/is/
路径开始。
到目前为止,我所做的是,
的routing.yml
user:
resource: "@UserBundle/Resources/config/routing.yml"
prefix: /is/
app:
resource: '@AppBundle/Controller/'
type: annotation
security.yml
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/.*, role: ROLE_SUPER_ADMIN }
但没有取得成功。我哪里错了,我该怎么做?
修改 - 当前行为
目前我转到https://example.com/is/
由于https://example.com/login
中的access_control
,我将我重定向到security.yml
。
如果我输入https://example.com/is/login
,则会显示404 Path not found
错误。
答案 0 :(得分:1)
在routing.yml
中使用此yml:
resource: "@AppBundle/Controller/"
type: annotation
prefix: /is
看看是否有效。
编辑#2
同样更改security.yml:
access_control:
- { path: ^/is/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/.*, role: ROLE_SUPER_ADMIN }
答案 1 :(得分:1)
resource: "@AppBundle/Controller/"
type: annotation
prefix: /is
然后你需要将/ login url放在IS_AUTHENTICATED_ANONYMOUSLY后面或者你在登录时永远不会访问登录页面
access_control:
- { path: ^/is/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/is/.*, role: ROLE_SUPER_ADMIN }