Symfony3 - 将基数 URL 更改为“/is”

Symfony3 - Change base URL to "/is"

我是 Symfony3 的新手。

我应该怎么做才能将我的基础 url 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_controlsecurity.yml

如果我输入 https://example.com/is/login,它会显示 404 Path not found 错误。

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 }
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 }