问题
*Hello there, I come here cause i found 0 solutions from now ... I started using FosUserBundle and was enjoying the functionalities ! But cause there is a but ... :p
When i try to go in the login page it's ok : app_dev.php/login
Now i try all the other links : /profile - /register - /resetting no one can load css and js ...
So i search why and i find this :
From /login i need to do ../css/images or ../js/vendor for exemple
From /register or the two other links i need to do ../../css/images or ../../js/vendor
Why this change ? why Symfony cannot load css and js from the same path ? It's annoying cause working like this i can't see and modify the templates easily on fosuserbundle.
I only modified routing.yml and security.yml :
# routing.yml
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
And then security
# app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
check_path: /login_check
login_path: /login
provider: fos_userbundle
logout:
path: /logout
target: /
# provider: fos_userbundle
# csrf_provider: form.csrf_provider
remember_me:
key: %secret%
lifetime: 300000000
path: /
domain : ~
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
If someone have an idea or the same resolved issue ;) Thanks in advance and have a nice day !!
来源:https://stackoverflow.com/questions/30194433/symfony-2-css-and-js-not-loaded-using-fosuserbundle-routing-bad-links