SSL on Dreampress - multiple redirects


#1

Hi all

I have followed the advice on setting up SSL on Dreampress on this article:

RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

In terms of adding the above to my .htaccess code, it creates multiple redirects which slows down the loading time, for example:

http://google.com --> 301 to https://google.com 301 to --> https://www.google.com

My wordpress settings are set to add ‘www.’ to all webpages. Is there anyway to get around this .htaccess code so that only one redirect is ever needed?


#2

%{HTTP_HOST} basically just means “whatever hostname was in the request”. So replace %{HTTP_HOST} with your full domain name to make it redirect straight to the correct domain, e.g.

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://www.example.com%{REQUEST_URI} [R,L]

#3

Thanks Andrew, that seems to have worked OK, but now there is a 302 redirect rather than a 301 redirect in the below?:

http://google.com -> https://www.google.com


#4

Ah nevermind, figured it out…

RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule .* https://www.example.com%{REQUEST_URI} [L,R=301]