awesome-fc / fc-wordpress

deploy a wordpress on FC
63 stars 8 forks source link

能否实现一下伪静态? #6

Closed cuteist closed 4 years ago

cuteist commented 4 years ago

我尝试将index.php的php script部分修改为

    if (preg_match('#\.php.*#', $uri) or preg_match('#/archives.*#', $uri)) {
        try{
            if (preg_match('#/archives.*#', $uri)) {
                $cgi_params = [
                    'HTTP_HOST' => $host, 'SERVER_NAME' => $host, 'SERVER_PORT' => '443',
                    'REQUEST_URI' => 'index.php'.$uri
                ];
            } else {
                $cgi_params = ['HTTP_HOST' => $host, 'SERVER_NAME' => $host, 'SERVER_PORT' => '443'];
            }
            $resp = $GLOBALS['fcPhpCgiProxy']->requestPhpCgi(
                    $request, $root_dir, "index.php", $cgi_params,
                    ['debug_show_cgi_params' => true, 'readWriteTimeout' => 5000]
                );
            return $resp;
        } catch (Exception $e){
            $GLOBALS['fcPhpCgiProxy'] = new \ServerlessFC\PhpCgiProxy();
            $resp = $GLOBALS['fcPhpCgiProxy']->requestPhpCgi(
                    $request, $root_dir, "index.php",
                    ['HTTP_HOST' => $host, 'SERVER_NAME' => $host, 'SERVER_PORT' => '443'],
                    ['debug_show_cgi_params' => true, 'readWriteTimeout' => 5000]
                );
            return $resp;
        } 
    }

但这样做,当我访问http://example.com/archives/example.html 时,会显式的跳转为http://example.com/index.php/archives/example.html

rsonghuster commented 4 years ago

https://yq.aliyun.com/articles/684764

尝试参考下这个?

rsonghuster commented 4 years ago

或者您这边直接基于函数计算的 custom runtime 实现, https://github.com/awesome-fc/customruntime-php; 跟传统的玩法一样, nginx+php-fpm, 直接在nginx 设置 rewrite即可

ryan7n commented 2 years ago

膜拜大佬们,都玩出花了