FatFree路由在生产中不起作用


FatFree routing not working in production

我有一个应用程序,它有许多路由路径,如下所示-

F3::route('GET /', 'Main->get_front_page');
F3::route('GET /login/check_for_login', 'Login->check_for_login');

第一条路线匹配正确。然而,第二条路线不匹配,我得到了404。事实上,第一条路线之后的任何路线都不匹配。

更复杂的是,所有的路线都在我的本地机器上运行。

检查您的apache.htaccess文件。尤其是RewriteBase url。我经常忘记这个:)

对于共享主机,fatfree框架部署不会像在本地服务器中那样工作。所以你需要创建一个.htaccess文件

# Enable rewrite engine and route requests to framework
RewriteEngine On
# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
# RewriteBase /
RewriteRule ^(tmp)'/|'.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]

使用上面的代码创建一个.htaccess文件,并将该文件放在您的无胖框架项目的根目录中。我试过这个,效果很好。