I'm trying to get a wordpress site to HTTPS, but everything I try gives me a redirect loop. I've edited the htaccess, I've set it in PHP, I've even downloaded a wordpress plugin to convert it, but every method gives me a redirect loop error. I know that something has to be redirecting my https to http, but I don't know what. Here is my .htaccess file without any of the HTTPS settings in it:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And here's the PHP I'm trying to use in the header php file to conver the page to HTTPS:
if($_SERVER["HTTPS"] != "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}
You don't need a blanket redirect in .htaccess or in PHP. Go to Dashboard >> Settings and change your URLs to https. Then save permalinks.
You may want to find/replace any http URLs in post/page content, media URLs, etc, so you don't get redirects for those from http to https. Try interconnectit.com WordPress Serialized PHP Search Replace Tool
After https is working, use Firebug with Firefox, or use the developer tools in Chrome or Safari or IE to see if you are getting any "insecure content" errors from non-https URLs in any theme files.
You may need to change to a relative path for images in CSS files, i.e. background-image: url(http://example.com/themes/wp-content/theme/images/image.jpg)
to background-image: url(images/image.jpg)
And, you may need to remove the http
from absolute paths in php theme files, i.e. change 'http://example.com/image.jpg'
to '//example.com/image.jpg'
; that will allow your resources to default to https.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With