0

I want to run my site over https so I've updated both URLs in the settings page to have https instead of http. I've also added the following to my config file since their seemed to be an issue with Wordpress detecting SSL on my server:

$_SERVER['HTTPS'] = 'on';

Even after doing this though all of the links in the menus and anything that uses the bloginfo function still say http instead of https. How can I force Wordpress to output all links as https instead of http?

1

Is the site running on Apache? If so you could put this in your .htaccess file

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>

also if you need SSL in your admin area and login pages put this into wp-config.php

define('FORCE_SSL_ADMIN', true);

here's another way that is more generic:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • Is it possible to rewrite this to exclude the domain? So if you migrated the .htaccess file to another server it wouldn't redirect to the old domain? – jgraup Feb 28 '16 at 21:14
  • 1
    i added another approach that is generic – locomo Mar 2 '16 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.