4

We have a Symfony 1.4 project and are looking to force HTTPS for all pages in a symfony application using only the htaccess file. I know there are ways to do using filters but I want to know if it's possible to do without that first?

Here is the .HTACCESS file I currently am using but isn't working as expected...

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

I've also tried without success:

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

I am sure there is some quirk I am missing in doing this with Symfony as this is an easy task to do straight away. Any ideas?

2
  • Did you check this answer ? Commented May 22, 2012 at 13:41
  • Yea I saw that one and tried to modify it so that ALL pages were forces to SSL, the example the user only wanted a few select locations to force SSL andthe rest to be regular HTTP. I am no whiz with .htaccess files so there is a chance I wasnt doing it correctly Commented May 22, 2012 at 13:44

1 Answer 1

2

Regarding a previous answer, try:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Sign up to request clarification or add additional context in comments.

2 Comments

No dice... I put in the URL mysite.com and login, once logged in the pages are HTTP
Just tried on my local machine, and it works like a charm. Could edit your post with your full .htaccess ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.