We use SSL on the https://www version of our website.

Now I would like to disable the SSL connection on the https://non-www version of our website, so the result is:

  • https://non-www => SSL handshake
  • https://www => no SSL

Can this be done?

  • By "disable" I assume you mean that it should not be accessible, not redirect to something else? – MrWhite Feb 6 '15 at 11:43

You could do this in your .htaccess file:

RewriteEngine on 

# if https and starts with www, go to http version
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

# if not https and it doesnt start with www, go to https version
RewriteCond %{SERVER_PORT} !^80$
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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