Redirecting http to https for wordpress sites

I installed a security certificate and moved my site to https recently and took a bit of fiddling to get the redirect from the old URL of

http://rosacea-support.org/*

to

https://rosacea-support.org/*

Here is the fragment of code in .htaccess that will redirect all of the pages to their new https home.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(rosacea-support.org)$
RewriteRule .* https://rosacea-support.org%{REQUEST_URI} [R=301,L]

The main problem I had originally was that many of the other domains I have hosted on the same platform would redirect to the https://rosacea-support.org new address as well – breaking all those sites.

So including the extra RewrtieCond to match only 1 HTTP_HOST solved this problem.

Both conditions must be met, ie. https is not set, and the http host is rosacea-support.org, and then all URLs are rewritten, and redirected permanently to https:// instead.

 

Advertisements
Redirecting http to https for wordpress sites

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s