Forcing a specific page to use HTTPS with angularjs

后端 未结 1 934
自闭症患者
自闭症患者 2020-12-25 14:30

In our application we have a payment page that we want to use SSL on because we are handling credit card information. We\'ve already put in place rewrite rules for apache to

相关标签:
1条回答
  • 2020-12-25 14:56

    I had a similar problem, although was using $routeProvider in a SPA application. What I did was to enforce a redirect inside the controller:

    var forceSSL = function () {
        if ($location.protocol() !== 'https') {
            $window.location.href = $location.absUrl().replace('http', 'https');
        }
    };
    forceSSL();
    

    This though does reload all resources. However, this happens only once when switching to SSL mode.

    Note, the function is actually in a service so can be called from anywhere.

    I hope this helps.

    0 讨论(0)
提交回复
热议问题