Force HTTPS uses only HTACCESS in SYMFONY

We have a Symfony 1.4 project and we are trying to force https for all pages in a symfony application to use only the htaccess file. I know there are ways to do this with filters, but I want to know if this can be done without it?

Here is the .HTACCESS file that I am currently using, but does not work as expected ...

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_FILENAME} !-f

I also tried without success:

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

I am sure there are some quirks that I am missing in this with Symfony, as it is an easy task to do it right now. Any ideas?

+3
source share
1 answer

As for the previous answer , try:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
+1
source

All Articles