Symfony 4 FOSUserBundle重定向错误太多

I'm using FriendsOfSymfony UserBundle in Symfony 4 and PHP 7.2. I've already finished my project and want to deploy it. So I 1. Change php version in the server 2. Change in .env file dev to log 3. Just upload all my files to server (without dev cache, its too big)

After opened the window I can see many redirection in developmanager in Google Chrome. Always to /login. Ok, I've tried change the security.yml and other strange things what I found in the internet. Nothin works. I've tried to delete checking access in some routes and just test if it'll work, but also not.

My full security.yml security: encoders: FOS\UserBundle\Model\UserInterface: bcrypt providers: fos_userbundle: id: fos_user.user_provider.username_email

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
        logout: true
        anonymous: true

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: ROLE_ADMIN }
    - { path: ^/resetting, role: ROLE_ADMIN }
    - { path: ^/admin/, role: ROLE_ADMIN }
    - { path: ^/profile, role: ROLE_USER }
    - { path: ^/profile/edit, role: ROLE_USER }

access_denied_url: /

Anyone has this problem too?

I'd think your problem is related to your libraries. Try composer install or composer install --optimize-autoloader and make sure the bootstrap file exists in var, and that var/ is writable by the web server user. Finally clear your cache bin/console cache:clear --env=prod

I believe what causes this problem are routes that end with a slash: /, also called a 'trailing slash'. There are three solutions to this problem:

  1. Make sure none of your routes end with a trailing slash. This means you will also have to override some of the default routes of the FOSUser bundle, because there are some that end in /.
  2. Redirect all routes with a trailing slash. There is documentation on how to do this on the symfony website.
  3. Upgrade to symfony 4.1, where routes with a trailing slash are automatically redirected.