Zend - 有条件地重新路由所有页面

Rya*_*yan 1 redirect zend-framework reroute

如果条件通过,我希望能够将所有请求重新路由或重定向到我的网站到特定页面.我假设这必须在引导程序或调度程序的某个地方完成,但我不确定最好/最干净的方法是什么.

没有.htaccess重定向,因为需要在PHP中测试条件

这是我想要的:

if( $condition ) {
    // Redirect ALL Pages/Requests
}

// else, continue dispatch as normal...
Run Code Online (Sandbox Code Playgroud)

这里的想法是我们可以设置整个网站并将所有内容发送到启动页面,直到指定的日期/时间,此时它本身将"自动启动".

tim*_*dev 5

为什么要麻烦路由?只是一个简单的重定向.

也许在Bootstrap.php中是这样的:

public function initSplash(){
    if($splashtime && $requestIsNotForComingSoonAlready){
        header('Location: /coming-soon',true,302);
        die();
    }
}
Run Code Online (Sandbox Code Playgroud)

或者您可以将if语句粘贴在index.php的顶部,并避免完全加载框架