Wordpress - https : Css and Js files are not working (load on http instead of https)

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

Topic http css https Wordpress

Category Web


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.


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.


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';

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.