i have moved my website to another server and changed the domain name, then i installed an SSL certificate, and when i change my website form http to https in wp-options and wp-config and also set a redirection to https in .htaccess my website didn't work only if i use http://mywebsite.com

and when i change the http to https://mywebsite.com via chrome tab the JS and CSS file only load http and the website doesn't look as it must

  • it's not enough to redirect CSS/JS to https, browsers will not attempt to load HTTP assets on a HTTPS page for security reasons, even if they redirect to secure locations
    – Tom J Nowell
    Aug 4, 2021 at 13:58

3 Answers 3


Add this code in to wp-config.php just before - require_once ABSPATH . 'wp-settings.php'; line

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';
  • Thank you i'll try this one
    – Norman
    Aug 4, 2021 at 11:12
  • 1
    That's for reverse proxies though. It doesn't sound like that's the problem here to me.
    – Rup
    Aug 4, 2021 at 15:08
  • this worked on my load balanced server. Thanks.
    – bperreault
    Apr 6, 2022 at 23:28
  • I had this one in wp-config.php but it needed to go as well to wp-settings.php for me
    – Djidiouf
    Apr 5, 2023 at 4:55

What URL are you using in the WordPress general options (/wp-admin/options-general.php)? HTTP or HTTPS? You should make sure you put your HTTPS address there.

Also it might help to re-save your permalinks.

  • Can you be please more specific ? is there a function a should look for in order the check HTTP/HTTPS... i'm newbie to wordpress Sorry
    – Norman
    Aug 4, 2021 at 10:36
  • 1
    @Norman Go to yourdomain.com/wp-admin/options-general.php (when logged in). There you'll see two text input's with your website URL. Can you validate if you see your website URL with HTTPS (instead of HTTP)? Alternatively, you can go to Settings → General (same thing).
    – DeltaG
    Aug 4, 2021 at 13:27

You can try some Apache code in your .htaccess file to redirect any http to https. And make sure wordpress settings are pointing to https and not http.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST}  "www.domain.com"
RewriteRule ^(.*)$ https://domain.com%{REQUEST_URI} [L,R=301]

Sorry about syntax highlighting. Not sure what the language code is for Apache directives on here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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