Issue with SetEnvIf

m running the latest version of Litespeed Web Server Enterprise v4.2.6 and I have a apache .htaccess file, a load balancer in front of a litespeed cluster and im running magento. Sites SSLs are accelerated at the load balancer and so when magento redirects to HTTPs it needs to think its already there when in reality the SSL connection is terminated at the load balancers and from the LBs to litespeed its only HTTP. To do this I need the following to work in the .htaccess file for litespeed:

SetEnvIf X-Forwarded-Proto https HTTPS=on

Currently when litespeed is enabled, magento just does a 301 redirect forever since it doesnt see its in HTTPS via the X-Forwarded-Proto header the Load Balancers are sending. I need this or a way to do the same in litespeed. I tried the following but it didnt work.

RewriteCond %{HTTP:X-Forwarded-Proto} ^https$
RewriteRule .* - [E=HTTPS:eek:n]


should be

RewriteCond %{HTTPS} on
RewriteRule .* - [E=X-Forwarded-Proto:https]

Sorry this looks wrong.

RewriteCond %{HTTP:X-Forwarded-Proto} ^https$
RewriteRule .* - [E=HTTPS:eek:n]
not working should due to HTTPS:eek:n/off can't be overridden.

I did a quick search just now, you may need modify the php code:
Put the following above the Mage::run... line at the bottom of your index.php to prevent this issue without overriding any Magento code:

This example is for Amazon EC2, but if your load balancer uses a different header, just change the `HTTP_X_FORWARDED_PROTO` portion.
* EC2's load balancer sets these for us so we know we're secure,
* preventing Magento from performing a redirect loop.
$_SERVER['HTTPS'] = 'on';
Last edited:
Can you add the ability to override it via such a line, as its important to have it in the .htaccess file then in the code directly due to code updates or even other software behind SSL load babalancers lacners that are not magento.
Also the php code you gave us works for checkout, but breaks the login to the admin area and the client couldnt login to the admin area, so the only work around is the apache SetEnvIf.