Symfony2 dev环境工作,prod env给出404错误[symfony2]

时间:2017-05-25 17:17:31

标签: php .htaccess symfony http-status-code-404

http://127.0.0.1/symfony/public_html/app_dev.php/home

一切正常

但是,当我尝试访问prod环境时,出现以下错误:

http://127.0.0.1/symfony/public_html/home
  

糟糕!发生错误服务器返回“404 Not Found”。

     

有些东西坏了。请告诉我们你在做什么   发生了错误。我们会尽快修复它。对不起   造成的不便。

我在routing.yml检查了我的所有路线,一切似乎都没问题。

我有 手动删除 专业版和开发缓存,我还运行了以下cmd:

php app/console --env=prod cache:clear

php app/console cache:warmup --env=prod --no-debug

如果我跑:

php app/console debug:router --env=prod

找不到路线

但是

php app/console debug:router --env=dev

找到所有路线

app.php

<?php

use Symfony\Component\HttpFoundation\Request;

/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache';

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

app_dev.php

<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
//use Sonata\PageBundle\Request\RequestFactory;

// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')) || php_sapi_name() === 'cli-server')
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../app/autoload.php';
Debug::enable();

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

的.htaccess

DirectoryIndex app.php

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    # Sets the HTTP_AUTHORIZATION header removed by apache
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

routing_dev.yml

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

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

_errors:
    resource: '@TwigBundle/Resources/config/routing/errors.xml'
    prefix: /_error

_main:
    resource: routing.yml

的routing.yml

c8cac8cacontent:
    resource: "@c8cac8cacontentBundle/Resources/config/routing.yml"
    prefix:   /

c8cac8cacontent_homepage:
    path:     /home
    defaults: { _controller: c8cac8cacontentBundle:Default:index }

about:
    path:     /about_us
    defaults: { _controller: c8cac8cacontentBundle:Default:about }

专业日志:

[2017-05-25 20:32:23] app.DEBUG: Router Symfony\Bundle\FrameworkBundle\Routing\Router was not able to match, message "" [] []
[2017-05-25 20:32:23] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /home"" at C:\xampp\htdocs\c8ca1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php line 176 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /home\" at C:\\xampp\\htdocs\\c8ca1\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\EventListener\\RouterListener.php:176, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): None of the routers in the chain matched this request\nGET /c8ca1/public_html/home HTTP/1.1\r\nAccept:                    text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Encoding:           gzip, deflate, sdch, br\r\nAccept-Language:           en-GB,en;q=0.8,en-US;q=0.6,fr;q=0.4\r\nCache-Control:             max-age=0\r\nConnection:                keep-alive\r\nCookie:                    PHPSESSID=hq2cc02hk5n0m5j310ib6jdm21\r\nHost:                      127.0.0.1\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent:                Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36\r\nX-Php-Ob-Level:            1\r\n\r\n at C:\\xampp\\htdocs\\c8ca1\\vendor\\symfony-cmf\\routing\\ChainRouter.php:207)"} []
[2017-05-25 20:32:24] app.DEBUG: Router Symfony\Bundle\FrameworkBundle\Routing\Router was not able to match, message "" [] []
[2017-05-25 20:32:24] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /home"" at C:\xampp\htdocs\c8ca1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php line 176 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /home\" at C:\\xampp\\htdocs\\c8ca1\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\EventListener\\RouterListener.php:176, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): None of the routers in the chain matched this request\nGET /c8ca1/public_html/home HTTP/1.1\r\nAccept:                    text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Encoding:           gzip, deflate, sdch, br\r\nAccept-Language:           en-GB,en;q=0.8,en-US;q=0.6,fr;q=0.4\r\nCache-Control:             max-age=0\r\nConnection:                keep-alive\r\nCookie:                    PHPSESSID=hq2cc02hk5n0m5j310ib6jdm21\r\nHost:                      127.0.0.1\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent:                Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36\r\nX-Php-Ob-Level:            1\r\n\r\n at C:\\xampp\\htdocs\\c8ca1\\vendor\\symfony-cmf\\routing\\ChainRouter.php:207)"} []
[2017-05-25 20:32:25] app.DEBUG: Router Symfony\Bundle\FrameworkBundle\Routing\Router was not able to match, message "" [] []
[2017-05-25 20:32:25] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /home"" at C:\xampp\htdocs\c8ca1\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php line 176 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /home\" at C:\\xampp\\htdocs\\c8ca1\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\EventListener\\RouterListener.php:176, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): None of the routers in the chain matched this request\nGET /c8ca1/public_html/home HTTP/1.1\r\nAccept:                    text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Encoding:           gzip, deflate, sdch, br\r\nAccept-Language:           en-GB,en;q=0.8,en-US;q=0.6,fr;q=0.4\r\nCache-Control:             max-age=0\r\nConnection:                keep-alive\r\nCookie:                    PHPSESSID=hq2cc02hk5n0m5j310ib6jdm21\r\nHost:                      127.0.0.1\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent:                Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36\r\nX-Php-Ob-Level:            1\r\n\r\n at C:\\xampp\\htdocs\\c8ca1\\vendor\\symfony-cmf\\routing\\ChainRouter.php:207)"} []

0 个答案:

没有答案