Scott C Wilson
Scott C Wilson

Reputation: 20016

www/non-www .htaccess issue

I have two sites on my hosting account:

business.com bookgroup.com

I want business.com to always be served with https. I don't have an SSL cert for bookgroup.com so it can stay http.

My .htaccess is:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^business\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

and this works perfectly for business.com. It also works for bookgroup.com. But when I do

http://www.bookgroup.com

It redirects to https://www.bookgroup.com.

How do I prevent this?

Upvotes: 1

Views: 18

Answers (1)

anubhava
anubhava

Reputation: 785176

This rule will only work for business.com domain due to first RewriteCond

RewriteCond %{HTTP_HOST} ^business\.com [NC]

You may have some other rule/code doing this or it is happening due to old browser cache.

There are several ways to verify:

  1. Completely clear your browser cache
  2. Use command line tools such as curl/wget to test it
  3. Use Incognito mode in Chrome with cache disabled
  4. Test in a different browser

Upvotes: 1

Related Questions