HTTP to HTTPS in my .htaccess

Right, now I know this has been covered a thousand times already, but it just won’t work for me in this instance, so please bear with me!

I would like to redirect all traffic from http to https, so in my .htaccess on site root I have the following:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Modrewrite is enabled on the host, but no rewriting seems to be happening.

Any ideas?

Hmm, that looks correct. You could try checking the port as HTTP runs through 80 by default and HTTPS though 443 by default.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Thanks JeffWalden, believe it or not, I’ve already tried that to no avail.
And yes, mod_rewrite is loaded in my httpd.conf…

Not sure what else could be stopping it from working…

Have you run the test I’ve suggested in my signature’s tutorial. Enabled is one thing but your host may not be allowing .htaccess (or some other problem). Run the test to see.

While you’re at it, look at the sample secure server codes, too, as you’re redirecting too much (IMHO).

Regards,

DK