Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无脂肪框架中的路由_Php_.htaccess_Routing_Fat Free Framework - Fatal编程技术网

Php 无脂肪框架中的路由

Php 无脂肪框架中的路由,php,.htaccess,routing,fat-free-framework,Php,.htaccess,Routing,Fat Free Framework,我已经开始学习无脂肪框架,安装后,当我写 require __DIR__.'/lib/base.php'; F3::set('DEBUG',3); F3::set('UI','ui/'); F3::route('GET /',function () {echo "hello";}); F3::run(); 在index.php中,它在屏幕上显示hello,但当我将其添加到上面时 F3::route('GET /about', function () {echo "hello";}); 当我打

我已经开始学习无脂肪框架,安装后,当我写

require __DIR__.'/lib/base.php';
F3::set('DEBUG',3);
F3::set('UI','ui/');
F3::route('GET /',function () {echo "hello";});
F3::run();
在index.php中,它在屏幕上显示hello,但当我将其添加到上面时

F3::route('GET /about', function () {echo "hello";});
当我打开localhost/freefat master/about时,屏幕上会显示“未找到页面”。以下是我的.htaccess文件的详细信息

# RewriteBase /
RewriteCond %{REQUEST_URI} \.ini$
RewriteRule \.ini$ - [R=404]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

我已经尝试将RewriteRule更改为/fatfree/index.php。请给我提个建议。我使用的是linux、mysql和apache。

如果你真的想打开

localhost/freefat-master/about
你最好确定这是实际的路径。通常叫

localhost/fatfree-master/about

显然,您可能已经更改了此项。

您不必更改
.htaccess
中的任何内容,除了
RewriteBase
行。把它改成

RewriteBase/fatfree master/


它应该可以工作。

刚刚在/etc/apache2/000 default中添加了一个新参数'SERVERNAME',它工作了,这要感谢所有的回复程序。

事实上,我已经编写了localhost/fatfree master/about,但这也不起作用。你说“你已经编写了”是什么意思您是否使用了在.htaccess中编写的url?是否可以尝试将适用于您的问题的url复制到您的问题中?如果第一条路径有效,第二条也应该有效。我使用了路径localhost/fatfree master/about,但这不起作用,我认为您的URL与.htaccess中的URL不匹配-在上面的评论中,您在rewritebase中编写了/fatfree/但您尝试访问fatfree master。你最初写的第一个例子是有效的-什么是有效的URL?仍然不起作用。请告诉我一些我遇到的问题,这里是mod_rewrite,甚至安装在你的服务器上,它被激活了吗?不,我不知道,请告诉我我使用sudo a2enmod rewrite检查了所需的步骤,它说模块重写已经启用。嗯,我也忘了提到,您必须删除.htaccess第一行前面的
#
。#是注释,将禁用该行。