Petter
Petter

Reputation: 783

Forcing non-SSL in htaccess only partly works

I have tried this in my htaccess file in order to force users accessing my page over SSL to be redirected to the non-SSL version:

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

This works when users are accessing the SSL version of www.mydomain.com, but not the SSL version of mydomain.com.

I think this is partly due to me having activated forwarding of users from mydomain.com to www.mydomain.com on my web-hosting provider control panel.

Does anyone know how to get both to work?

Upvotes: 0

Views: 50

Answers (1)

Ravi K Thapliyal
Ravi K Thapliyal

Reputation: 51711

How would the htaccess file look if I want to implement both? That is, forwarding non-www to www, as well as the SSL version of both non-www and www to non-SSL www?

RewriteEngine On

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

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

Upvotes: 1

Related Questions