How to force https for prod but http for dev environment?

后端 未结 4 1392
孤街浪徒
孤街浪徒 2021-02-02 11:13

I have a symfony2 application.

On the prod server I want all my routes to go via https, while in dev I want to be able to use http. How do I achieve that with symfony2 a

4条回答
  •  遥遥无期
    2021-02-02 11:16

    I think you can check the scheme in app_dev.php file and base on that redirect it to https

    $url = parse_url($_SERVER['HTTP_REFERER']);
    if ($url['scheme'] == 'http') {
       header("Location: https://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}");
    }
    

    Or maybe able to apply some changes in .htaccess for app_dev.php in URL

提交回复
热议问题