2016-06-24 11 views
0

現在、fat-freeフレームワークでルーティングの問題が発生しています。私はこれまで単純な問題に見えても解決できませんでした。私は、ルートディレクトリからF3の標準のルーティング・フォーマットを使用してい脂肪フリーのPHP無効なルート

$f3->route(array('GET /', 'GET /index.php'), function($f3) { 
    include 'header.html'; 
    include 'Home/index.html'; 
    include 'footer.html'; 
}); 

//search 
$f3->route('GET /Browse', function() { 
    include 'Browse/index.html'; 
}); 

これらのルートの両方の仕事を正しく予想通り。 xammpにlocalhostと入力すると、両方ともアウトラインのページが返されます。私はindex.htmlファイルとフォルダを持っているし、代わりにHTMLをエコーすることによって応答したくない新しいルートを定義した後

-Root 
-index.php 
-header.html 
-footer.html 
--Browse 
---index.html 

:どちらも、ファイル構造を持っています。

$f3->route('GET /Latest', 
    function() { 
     include 'submit/index.html'; 
     echo 'This is our home page.'; 
    } 
); 

私は上記のコードを使用して、私はを提示しています/最新のlocalhostに行く:私の質問は、私は、その後のフォルダを持たずにPHPからの応答を直接許可することができる方法である

Error 404 : Not found 

index.htmlファイル

おかげで、多くの点:)

答えて

1

あなたは、おそらくフレームワークtemplate engineを探しています。 、404エラーについては

// index.php 

$f3->UI='templates/'; 

$f3->route('GET /home',function($f3){ 
    $f3->main='home.html'; 
    $f3->title='Homepage'; 
    $tpl=Template::instance(); 
    echo $tpl->render('layout.html'); 
}); 

$f3->route('GET /contact',function($f3){ 
    $f3->main='contact.html'; 
    $f3->title='Contact us'; 
    $f3->address='5578 Grant Street Woodbridge, VA 22191'; 
    $tpl=Template::instance(); 
    echo $tpl->render('layout.html'); 
}); 
<!-- templates/layout.html --> 
<!DOCTYPE html> 
<title>{{ @title }}</title> 

<body> 
    <include href="header.html"/> 
    <main> 
    <include href="{{ @main }}"/> 
    </main> 
    <include href="footer.html"/> 
</body> 
<!-- templates/home.html --> 
<h1>Hey hey! Welcome home!</h1> 
<!-- templates/contact.html --> 
<h1>Our address</h1> 
<p>{{ @address }}</p> 

はあなたのコードを構造化する様々な方法がありますが、ここでは迅速な基本的な例です。あなたのを確認してくださいファイルが正しく設定されています(特にRewriteBaseディレクティブ)。そうでない場合、/以外のすべてのURIは404をスローします。設定の詳細については、hereを参照してください。

+0

ああ、ありがとう、私の評判が高くなるまで、id upvoteしかし、サイト上で傾ける。しかし、おかげさまで私はこれが私が探していたものだと思っています:) – D3181

関連する問題