Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've got an ecommerce site where we're have some reports (random) of the cart not operating correctly. I think it might be due to removing www not working with https

my current htaccess code looks like this:

# remove the www
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

What do I need to do to also force this on https?

share|improve this question

1 Answer

up vote 1 down vote accepted

This looks like the same situation covered here: http://stackoverflow.com/questions/3634101/url-rewriting-for-different-protocols-in-htaccess

Here is the code for removing the www from your hosts, regardless of http or https protocol

RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{HTTPS}s ^on(s)|off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.