2
我在我的PHP項目中使用Klein.php進行路由。我的項目目錄具有以下結構:使用Klein-PHP來過濾請求
myProject
|
*---Restricted--
| |
| *---index.php
| |
| *---blah.html
| |
| *---some_directory
|
|
*---some_other_directories
|
*---index.html
|
*---fun.html
|
*---css
|
*---js
我想是處理所有請求,只Restricted
文件夾。對於其他任何事情,我只是希望服務器完成其工作,即只需提供其餘文件。
我該如何做到這一點?
編輯
我有它配置爲通過CORY在回答給:
// .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
和
// index.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$klein = new \Klein\Klein();
$klein->respond('@^/Restricted/', function() {
// checking if authenticated user
});
$klein->dispatch();
?>
如何你現在有配置嗎? –
@Cᴏʀʏ請求說,'blah.html'應該被轉發到index.php,但對於像'fun.html'這樣的文件,它應該被簡單地提供。現在只有那些在index.php中定義了一些匹配規則的鏈接才能工作,其餘的我會看到一個空白頁面。 – asaini