3

i have the following in my .htaccess file to redirect http requests to https

RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_HOST} ^newco.local,^newco.dev
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

this redirects correctly in firefox but not chrome or safari. this is hosted on phpfog at http://newco.phpfogapp.com the ssl terminates at the load balances so i had to use %{HTTP:X-Forwarded-Proto} to check for https. could this be causing any issues with other browsers? any ideas?

Austin
  • 1,129
  • 2
  • 11
  • 18

1 Answers1

-1

Try the %{HTTPS} variable.

If the request is HTTPS, the variable =on, otherwise, it =off.

Example Code:

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^newco.local,^newco.dev
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Here is the full Apache Mod_Rewrite Documentation

Scott Stevens
  • 2,546
  • 1
  • 20
  • 29
  • OP clearly stated that HTTPS ends at the load balancer, so all requests get on port 80 (normal HTTP) at apache, so `RewriteCond %{HTTPS} !=on` is not an option. – Eduard Luca Oct 19 '12 at 23:44