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