4
votes

I want to change the default protocol used with link_to and url_for function from symfony. I dind't find any good way on the documentation. My solution is to generate absolute url and subsitute the http: by an https:, i don't find it clean and nice.

So do you have an answer?

Thanks.

1
Hm, as far as I know, and it's stated in the docs, you can specify protocol of your uri for absolute paths: echo link_to('Visit Hoogle', 'http://www.hoogle.com'); - Yaronius
OK but what can i do with something like this : link_to('info', '@info'); - Brice Favre

1 Answers

3
votes

You can set sfRouting parameters to generate https urls or urls with a different protocol. Check out the sfRouting::fixGeneratedUrl method.

However, if you're only interested in this for generating https links, I strongly recommend using a filter approach. The sfSslRequirementPlugin was written for 1.1, but will work with some modifications. Alternatively, there's this solution written for 1.3/1.4, but I have never used it.

A filter approach is required to ensure that your secure actions are only being accessed securely and will let you be unconcerned with how URLs are generated.