簡體   English   中英

Symfony2:在此服務器上找不到請求的URL /app_dev.php/security/login_check

[英]Symfony2: The requested URL /app_dev.php/security/login_check was not found on this server

每當我嘗試登錄時都會遇到問題,但是僅在上載站點的Ubuntu Server上會出現此問題,並且在Windows上使用Wamp可以正常工作。

我不知道這是怎么回事。 我在日志文件上看不到任何內容。

這是security.yml文件:

security:
    encoders:
        Op\AppSecurityBundle\Entity\User: sha512
        Symfony\Component\Security\Core\User\User: plaintext

providers:
    default:
        entity: { class: AppSecurityBundle:User, property: email }

role_hierarchy:
    ROLE_OPTIME_ADMIN:  ROLE_OPT_USER
    ROLE_SUPER_ADMIN:   [ROLE_OPT_USER, ROLE_OPT_ADMIN, ROLE_ALLOWED_TO_SWITCH]

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    prizes:
        pattern:    ^/admin|^/security|^/landing|^/reports|^/catalog
        form_login:
            check_path: /security/login_check
            login_path: /
            provider: default
            success_handler: whos_online
            failure_handler: whos_online
        logout:
            path:   /security/logout
            target: /
            success_handler: whos_online

access_control:
    - { path: ^/admin, roles: [ROLE_OPT_ADMIN] }
    - { path: ^/security, roles: [ROLE_OPT_ADMIN, ROLE_OPT_USER] }
    - { path: ^/landing, roles: [ROLE_OPT_ADMIN, ROLE_OPT_USER] }
    - { path: ^/reports, roles: [ROLE_OPT_ADMIN, ROLE_OPT_USER] }
    - { path: ^/catalog, roles: [ROLE_OPT_ADMIN] }

routing_dev.yml

_assetic:
    resource: .
    type:     assetic

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_main:
    resource: routing.yml

routing.yml

ws:
    resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
    prefix:   /ws

security:
    resource: @AppSecurityBundle/Resources/config/routing.yml

parameter:
    resource: @ParameterBundle/Resources/config/routing.yml

status:
    resource: @AppStatusBundle/Resources/config/routing.yml

csc:
    resource: @CSCBundle/Resources/config/routing.yml

catalog:
    resource: @CatalogBundle/Resources/config/routing.yml

prizes:
    resource: @PrizesBundle/Resources/config/routing.yml

reports:
    resource: @ReportsBundle/Resources/config/routing.yml

AppSecurityBundle / Resources / config / routing.yml

_security:
    resource: "@AppSecurityBundle/Controller/AppSecurityController.php"
    type:     annotation

AppSecurityController.php中的注釋

            /**
     * @Route("/", name="_login")
     * @Template()
     */
    public function loginAction( )
    {
         //hidden
        }

/**
     * @Route("/security/login_check", name="_security_check")
     */
    public function securityCheckAction( )
    {
        // The security layer will intercept this request
    }

    /**
     * @Route("/security/logout", name="_logout")
     */
    public function logoutAction( )
    {
        // The security layer will intercept this request
    }

    /**
     * @Route("/landing", name="_landing")
     * @Template()
     */
    public function landingAction( )
    {
        return array ( );
    }

如果這是一個愚蠢的問題,我深表歉意。 我不知道為什么它在本地但不在服務器上工作。

我正在使用Symfony 2.0.12和Ubuntu Server 11.10

補充:當我運行php app /控制台路由器:調試時,我得到了

[router] Current routes
Name                     Method Pattern
_wdt                     ANY    /_wdt/{token}
_profiler_search         ANY    /_profiler/search
_profiler_purge          ANY    /_profiler/purge
_profiler_import         ANY    /_profiler/import
_profiler_export         ANY    /_profiler/export/{token}.txt
_profiler_search_results ANY    /_profiler/{token}/search/results
_profiler                ANY    /_profiler/{token}
_webservice_call         POST   /ws/{webservice}
_webservice_definition   GET    /ws/{webservice}
_login                   ANY    /
_security_check          ANY    /security/login_check
_logout                  ANY    /security/logout
_landing                 ANY    /landing
_concurrency             ANY    /security/concurrency
_overwriteConcurrency    ANY    /security/overwriteConcurrency
_loading                 ANY    /security/loading
_changeLanguage          ANY    /changeLanguage
_security                ANY    /security/{strategy}/{globalStrategy}
_parameter               ANY    /admin/{strategy}/{globalStrategy}
_status                  ANY    /admin/{strategy}/{globalStrategy}
_csc                     ANY    /admin/{strategy}/{globalStrategy}
_catalogs                ANY    /catalog/{strategy}/{globalStrategy}
_prizes                  ANY    /admin/{strategy}/{globalStrategy}
_reports                 ANY    /{globalStrategy}/{strategy}

曾經有過同樣的問題,在我的情況下,我沒有很好地配置我的服務器,我通過使用rewrite模塊配置apache2來解決它,在linux中,應該通過諸如sudo a2enmod rewrite這樣的方式進行修復,並在etc / apache中的站點配置站點中加上/sites-available/example.dev您應該有類似這樣的內容

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
  ServerName example.dev
  DocumentRoot "/var/www/intranetcms/web"
  DirectoryIndex app.php
  <Directory "/var/www/intranetcms/web">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

如果您不知道如何配置本地域,請參見http://tutorial.symblog.co.uk/docs/configuration-and-templating.html示例,但是如果您不想配置本地域,則可以檢查默認值/ etc / apache2 / sites-enabled / default中的站點配置文件,並將AllowOverride None更改為AllowOverride All

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM