2017-01-22 6 views
2

이 코드는 heroku의 예제에서 나온 것입니다. 그러나 경로 /를 제외하고 내가 추가 한 다른 것은 작동하지 않습니다. 이 제품은 404 :"/"를 제외한 Heroku silex 루트 쇼 404

을 보여줍니다. 요청하신 URL/e은이 서버에서 발견되지 않았습니다. (각 지점을 마스터 추진에 Heroku가 자동 빌드)

$app->match('/', function(Symfony\Component\HttpFoundation\Request $request) use ($app) { 
    return $app['twig']->render('index.twig'); 
}); 

$app->match("/dump", function(Symfony\Component\HttpFoundation\Request $request) use ($app) { 
    return new Response('Thank you for your feedback!', 201); 
})->bind("dump"); 
$app->get("/t", function() use ($app) { 
    return new Response('Thank you for your feedback!', 201); 
})->bind("t"); 
$app->get("/d", function() { 
    return new Response('Thank you for your feedback!', 201); 
})->bind("d"); 
$app->get("/e", function() { 
    return new Response('Thank you for your feedback!', 201); 
}); 
$app->run(); 

편집 한 내가 직접 Heroku가 서버에 배포

편집 2 내 작업 공간 :

bin\worker.php 
www\index.php <== the snippet is from this file 
www\list.php 
apache_app.conf 
app.php <== basic init, return Silex\Application $app 
Procfile 

apache_app.conf의 내용은에서 복사됩니다. 210. 한다 RewriteEngine는

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

RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 

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

RewriteRule .? %{ENV:BASE}/app.php [L] 

에 나는 어떻게 든 아파치 설정을 변경해야한다고 생각하지만, 나는 htaccess로 구문을 이해하지 않습니다. 내용으로의 nginx의 conf 파일을 생성, nginx를 들어

web: vendor/bin/heroku-php-apache2 web/ 

:

+0

은'/ index.php/e'가 작동합니까? 웹 서버를 구성 했습니까? 당신은 아파치 또는 nginx를 사용하고 있습니까? – Federkun

+0

@Federkun 아니, 아무도 작동하지 않습니다. 내가 heroku 서버에 배포 한 이래로 나는 그것으로 설정을 할 수 있다고 생각하지 않는다. 그리고 내가 아는 한, 그들은 apache2를 사용하고 있습니다. – Ngoc

+0

http://silex.sensiolabs.org/doc/2.0/web_servers.html#apache를 참조하십시오. '/ index.php/e' ('/ index.php'는 프론트 컨트롤러입니다)가 작동해야합니다. '/ index.php'로 갈 때, 인덱스 페이지를 올바르게 반환하고 있습니까? – Federkun

답변

0

아파치를 들어, 귀하의 Procfile를 "/ 웹"내

<IfModule mod_rewrite.c> 
    Options -MultiViews 

    RewriteEngine On 
    #RewriteBase /path/to/app 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [QSA,L] 
</IfModule> 

를 htaccess로 파일을 추가하고 설정할 수 있습니다 :

location/{ 
    # try to serve file directly, fallback to rewrite 
    try_files $uri @rewriteapp; 
} 

location @rewriteapp { 
    # rewrite all to index.php 
    rewrite ^(.*)$ /index.php/$1 last; 
} 

location ~ ^/(index|index_dev)\.php(/|$) { 
    try_files @heroku-fcgi @heroku-fcgi; 
    internal; 
} 

과 같은 Procfile을 설정

,
web: vendor/bin/heroku-php-nginx -C server_conf/nginx.conf web/