poh
poh

Reputation: 171

Symfony 1.4 https

I need to assign https to my symfony 1.4 project. The only thing I have to change is htaccess or I'll have to write something in filters etc?

I'm asking because I tried to do this with htaccess but with no results.

Upvotes: 0

Views: 434

Answers (1)

user2413181
user2413181

Reputation:

You can use filter to do it ,like this

class sfSecureFilter extends sfFilter
{
    public function execute($filterChain)
    {
        $context = $this->getContext();
        $request = $context->getRequest();

        if (!$request->isSecure())
        {
            $secure_url = str_replace('http', 'https', $request->getUri());

            return $context->getController()->redirect($secure_url);

        }
        else
        {
            $filterChain->execute();
        }
    }
}

Upvotes: 1

Related Questions