Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have 2 rules on my site: one to force the www subdomain, and another to force the HTTP protocol:

  RewriteEngine On
  RewriteBase /

  RewriteCond %{HTTPS} =on
  RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

If I type https://example.com, it is correctly redirected to http://www.example.com.

But if I type https://www.example.com, it isn't redirected to http. It remains in HTTPS.

Why isn't this working?

share|improve this question
    
This doesn't result in a redirect loop for you? –  nathangiesbrecht Mar 20 at 17:51
    
Apologies, I typed the example code wrong. –  kgrote Mar 20 at 18:08
    
It's not giving you any error at all, just not redirecting? When I copy your htaccess into one of my own sites, it works as expected. Maybe try removing the = on the "RewriteCond %{HTTPS} =on" line? You don't need the = there... –  nathangiesbrecht Mar 20 at 18:21
    
@nathangiesbrecht Nope, no errors at all. Removing the = didn't have any effect. –  kgrote Mar 20 at 20:35
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.