【问题标题】:PHP fat-free-framework not route under https redirectPHP无脂肪框架在https重定向下不路由
【发布时间】:2019-12-28 21:40:43
【问题描述】:

我尝试在 https 下设置 PHP Fat-free framework(f3) 工作,但失败了。我在 http 下使用了 f3 路由,它在 Debian 10 + apache2 + PHP 7.3 环境中运行良好。最近我在 apache 上添加了一个自签名 ssl,然后所有 f3 路由都变成了 '404 not found on this server' 除了根路由($f3->route('GET /',...);)。

f3 路由的 apache 重写引擎在 http 协议下正常唤醒。改写规则来自f3官方建议(https://fatfreeframework.com/3.6/routing-engine#SampleApacheConfiguration),设置在站点文档根目录2级子目录下的.htaccess文件中。我在 .htaccess 中的“RewriteEngine On”之后添加了“RewriteBase /foo/bar/”。

这些示例 f3 路由代码位于 index.php 中。它们都在http协议下工作,只有'GET /'可以在https连接下工作。

  • http 工作,https 也工作。打印一个类似“hello world”的模板。
$f3->route('GET /', function($f3){
    $f3->set('name', 'f3-routing');
    $template = \Template::instance();
    echo $template->render('std2.html');
});
  • http 工作,打印'test1'; https 不起作用,在此服务器上找不到显示 URL。
$f3->route('GET /test1', function(){echo "test1";});
  • http工作,打印一个'hello world'样模板; https 不起作用,在此服务器上找不到显示 URL。
$f3->route(array('GET /@conf_id/@room_id'),
    function($f3, $params) {
        $template = \Template::instance();
        echo $template->render('disp_ppt.html');
    }
);

【问题讨论】:

  • SSL 网站通常在 apache 中有不同的配置文件。https.conf ..将其与您的 http.conf 进行比较,并进行所需的更改以使其运行.. 它可能类似于“此主机的 https apache 配置中不存在的 AllowOverwrite all"。

标签: php https routes fat-free-framework


【解决方案1】:

根据@ikkez 的建议。这似乎工作。但是有一点区别。 Debian 10 Apache2 中的 SSL 配置文件位于 /etc/apache2/sites-available/default-ssl.conf 中。似乎没有地方添加“AllowOverwrite all”。虽然我在 /etc/apache2/sites-available/000-default.conf 中有“AllowOverwrite all”,我认为它应该可以工作,但它没有。最终使重写路由起作用的是将 /etc/apache2/apache2.conf 从“AllowOverwrite None”更新为“AllowOverwrite all”。 我认为原因是:当系统运行http协议时,配置文件会直接使用000-default.conf;当系统运行 https 协议时,配置文件直接到 default-ssl.conf。此更改使 AllowOverwrite 在 https 下不起作用。更新 apache2.conf "AllowOverwrite all" 做了一个全局配置。

【讨论】:

    猜你喜欢
    • 2014-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-26
    相关资源
    最近更新 更多