1

So I recently, built and LAMP server and installed wordpress on it. I connected it to the web via a reverse ssh tunnel using serveo.net. I decided to add ssl and the rest of the website seem to work fine, but wordpress keeps breaking when I try to use ssl. I went to the general settings and changed the urls to http instead of https, but when I load the pages, in the source code the css and js urls are using http instead of https, so they won't load. Then wp-admin part won't even load. How do I fix this? I've looked at quite a few posts about people having similar problems, but none of them helped.

0

Check two things:

  • in the wp-options table, the site URLs (in two places) should be the full URL, as in https://www.example.com .
  • check the site's htaccess file for proper rewrite of http to https.

For a htaccess rule, this one works in most case:

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

Then look at your theme files to ensure that any references to CSS/JS include the https protocol, not http. Most well-written themes will use relative rather than absolute references to files to include.

It's also possible a plugin might be specifying http rather than https.

Use the Network tab in Developer Tools (usually F12 in your browser) to look at each request to see where it is coming from. If the request is to a plugin folder, then check the code in there.

  • I'm using the default theme. twentynieteen,I'm using the default theme. twentynieteen. The database entries are correct, but the head section has stuff like <link rel='stylesheet' id='wp-block-library-css' href='jtjumper.serveo.net/wp/wp-includes/css/dist/block-library/…' type='text/css' media='all' /> <link rel='stylesheet' id='wp-block-library-theme-css' href='jtjumper.serveo.net/wp/wp-includes/css/dist/block-library/…' type='text/css' media='all' /> – John Tippin Feb 3 at 23:29
  • If I look at the page source on my test (hosted) site with the 2019 theme, the href for those statements includes the https: protocol. And I have the htaccess shown in my answer. And my wp-options table contains example.com , not just www.example.com . Perhaps yours is not set up that way? – Rick Hellewell Feb 3 at 23:39
  • There's not enough space in the comments for the source but this is the link for the page jtjumper.serveo.net/wp my wp-options table has both, which are both https – John Tippin Feb 4 at 0:06
  • Do you have some caching plugin? Is your htaccess rewriting http to https? – Rick Hellewell Feb 4 at 1:03
  • the only plugins I have are akismet, loginizer, realy simple ssl, and wordfence – John Tippin Feb 4 at 1:22
0

Had the similar issue.

This answer solves most of the issues and I'm hoping you've gone through it.

The reason, I found, for HTTPS (SSL) not working on my Wordpress even after changing
1. Virtual Host File aka <web_directory>.conf file inside /ect/apache2/sites-available
2. wp-config file inside /var/www/<web_directory>/
3. [For AWS EC2 Users] Adding a load balancer with a SSL certificate for HTTPS connections

If after doing all this, you can view your website w/o CSS and JS working, then,

Last step

  1. Inside your Wordpress Dashboard, go to Settings>General

    Under, Wordpress Address (URL) add, https://<yourdomain>.com
    Under, Site Address (URL) add, https://<yourdomain>.com

I found that, when only Site Address (URL) has been activated with the website URL, Wordpress Themes automatically direct towards, the css files with HTTPS aka, https://<WordPressAddress>/css/index.css.

Only your domain has SSL access hence, adding your domain name at Wordpress Address (URL) solved the problems for me.

0

Add this code to wp-config.php in wordpress root folder. In general settings also change http to https.

define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
   $_SERVER['HTTPS']='on';

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.