fat-free framework only working through cli

2019-09-06 20:40发布

I just started trying to use the fat-free framework. I don't understand what i am doing wrong here. I have the following code that i got from their site:

$f3 = require('/var/tmp/fatfree-master/lib/base.php');
$f3->route('GET /',
    function() {
        echo 'Hello, world!';
    }
);

$f3->run();
?>

When i run the following code using the cli, like this php index.php it works fine. But when i try to go to it with a browser i get the following error:

Not Found

HTTP 404 (GET /index.php)

I don't understand how it works through cli and not through a browser. Anyone come across this before?

1条回答
甜甜的少女心
2楼-- · 2019-09-06 21:12

Forget everything about any PHP files in your URL. You don't need them and you don't use them in any URL. So, just open example.org/ instead of example.org/index.php and it will work.

Also make sure, as mentioned by Ben in the comments, to configure .htaccess properly as described here: https://github.com/bcosca/fatfree#sample-apache-configuration

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
查看更多
登录 后发表回答